VPN: Reload the tunnel before starting it up
To avoid errors like this: https://stackoverflow.com/q/47550706 Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
@@ -272,15 +272,18 @@ class TunnelContainer: NSObject {
|
|||||||
s.status = .inactive
|
s.status = .inactive
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.startObservingTunnelStatus()
|
s.tunnelProvider.loadFromPreferences { [weak s] (error) in
|
||||||
let session = (s.tunnelProvider.connection as! NETunnelProviderSession)
|
guard let s = s else { return }
|
||||||
do {
|
s.startObservingTunnelStatus()
|
||||||
let tunnelOptions = PacketTunnelOptionsGenerator.generateOptions(
|
let session = (s.tunnelProvider.connection as! NETunnelProviderSession)
|
||||||
from: tunnelConfiguration, withResolvedEndpoints: endpoints)
|
do {
|
||||||
try session.startTunnel(options: tunnelOptions)
|
let tunnelOptions = PacketTunnelOptionsGenerator.generateOptions(
|
||||||
} catch (let error) {
|
from: tunnelConfiguration, withResolvedEndpoints: endpoints)
|
||||||
os_log("Failed to activate tunnel: %{public}@", log: OSLog.default, type: .debug, "\(error)")
|
try session.startTunnel(options: tunnelOptions)
|
||||||
completionHandler(error)
|
} catch (let error) {
|
||||||
|
os_log("Failed to activate tunnel: %{public}@", log: OSLog.default, type: .debug, "\(error)")
|
||||||
|
completionHandler(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user