aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/VPN
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuard/VPN')
-rw-r--r--WireGuard/WireGuard/VPN/TunnelsManager.swift21
1 files changed, 12 insertions, 9 deletions
diff --git a/WireGuard/WireGuard/VPN/TunnelsManager.swift b/WireGuard/WireGuard/VPN/TunnelsManager.swift
index bfecfd6..76d5c05 100644
--- a/WireGuard/WireGuard/VPN/TunnelsManager.swift
+++ b/WireGuard/WireGuard/VPN/TunnelsManager.swift
@@ -272,15 +272,18 @@ class TunnelContainer: NSObject {
s.status = .inactive
return
}
- s.startObservingTunnelStatus()
- let session = (s.tunnelProvider.connection as! NETunnelProviderSession)
- do {
- let tunnelOptions = PacketTunnelOptionsGenerator.generateOptions(
- from: tunnelConfiguration, withResolvedEndpoints: endpoints)
- try session.startTunnel(options: tunnelOptions)
- } catch (let error) {
- os_log("Failed to activate tunnel: %{public}@", log: OSLog.default, type: .debug, "\(error)")
- completionHandler(error)
+ s.tunnelProvider.loadFromPreferences { [weak s] (error) in
+ guard let s = s else { return }
+ s.startObservingTunnelStatus()
+ let session = (s.tunnelProvider.connection as! NETunnelProviderSession)
+ do {
+ let tunnelOptions = PacketTunnelOptionsGenerator.generateOptions(
+ from: tunnelConfiguration, withResolvedEndpoints: endpoints)
+ try session.startTunnel(options: tunnelOptions)
+ } catch (let error) {
+ os_log("Failed to activate tunnel: %{public}@", log: OSLog.default, type: .debug, "\(error)")
+ completionHandler(error)
+ }
}
}
}