Skip to content

Commit 4fbdd0d

Browse files
author
mojganii
committed
Fix getting stuck after blocked state
1 parent 6aa0f47 commit 4fbdd0d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

ios/PacketTunnelCore/Actor/PacketTunnelActor.swift

+13-13
Original file line numberDiff line numberDiff line change
@@ -284,18 +284,17 @@ extension PacketTunnelActor {
284284
nextRelays: NextRelays,
285285
reason: ActorReconnectReason
286286
) async throws {
287+
defer {
288+
// Restart default path observer and notify the observer with the current path that might have changed while
289+
// path observer was paused.
290+
startDefaultPathObserver(notifyObserverWithCurrentPath: true)
291+
}
292+
287293
guard let connectionState = try obfuscateConnection(nextRelays: nextRelays, settings: settings, reason: reason),
288294
let targetState = state.targetStateForReconnect else { return }
289295

290296
let activeKey = activeKey(from: connectionState, in: settings)
291297

292-
switch targetState {
293-
case .connecting:
294-
state = .connecting(connectionState)
295-
case .reconnecting:
296-
state = .reconnecting(connectionState)
297-
}
298-
299298
let entryConfiguration: TunnelAdapterConfiguration? = if connectionState.selectedRelays.entry != nil {
300299
try ConfigurationBuilder(
301300
privateKey: activeKey,
@@ -330,19 +329,20 @@ extension PacketTunnelActor {
330329
*/
331330
stopDefaultPathObserver()
332331

333-
defer {
334-
// Restart default path observer and notify the observer with the current path that might have changed while
335-
// path observer was paused.
336-
startDefaultPathObserver(notifyObserverWithCurrentPath: true)
337-
}
338-
339332
try await tunnelAdapter.startMultihop(
340333
entryConfiguration: entryConfiguration,
341334
exitConfiguration: exitConfiguration
342335
)
343336

344337
// Resume tunnel monitoring and use IPv4 gateway as a probe address.
345338
tunnelMonitor.start(probeAddress: connectionState.selectedRelays.exit.endpoint.ipv4Gateway)
339+
340+
switch targetState {
341+
case .connecting:
342+
state = .connecting(connectionState)
343+
case .reconnecting:
344+
state = .reconnecting(connectionState)
345+
}
346346
}
347347

348348
/**

0 commit comments

Comments
 (0)