@@ -284,18 +284,17 @@ extension PacketTunnelActor {
284
284
nextRelays: NextRelays ,
285
285
reason: ActorReconnectReason
286
286
) 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
+
287
293
guard let connectionState = try obfuscateConnection ( nextRelays: nextRelays, settings: settings, reason: reason) ,
288
294
let targetState = state. targetStateForReconnect else { return }
289
295
290
296
let activeKey = activeKey ( from: connectionState, in: settings)
291
297
292
- switch targetState {
293
- case . connecting:
294
- state = . connecting( connectionState)
295
- case . reconnecting:
296
- state = . reconnecting( connectionState)
297
- }
298
-
299
298
let entryConfiguration : TunnelAdapterConfiguration ? = if connectionState. selectedRelays. entry != nil {
300
299
try ConfigurationBuilder (
301
300
privateKey: activeKey,
@@ -330,19 +329,20 @@ extension PacketTunnelActor {
330
329
*/
331
330
stopDefaultPathObserver ( )
332
331
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
-
339
332
try await tunnelAdapter. startMultihop (
340
333
entryConfiguration: entryConfiguration,
341
334
exitConfiguration: exitConfiguration
342
335
)
343
336
344
337
// Resume tunnel monitoring and use IPv4 gateway as a probe address.
345
338
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
+ }
346
346
}
347
347
348
348
/**
0 commit comments