diff options
author | Roopesh Chander <roop@roopc.net> | 2018-11-09 19:49:48 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-11-09 22:29:52 +0530 |
commit | 7485474c4ce5d03c3f90b699246f2ad96964be64 (patch) | |
tree | 780f67e06ebfad46c492d7a5f072b2c8f85c9336 /WireGuard/WireGuardNetworkExtension | |
parent | VPN: Refresh tunnel statuses when app gets to the foreground (diff) | |
download | wireguard-apple-7485474c4ce5d03c3f90b699246f2ad96964be64.tar.xz wireguard-apple-7485474c4ce5d03c3f90b699246f2ad96964be64.zip |
NE: Minor refactoring to enable calling startTunnel() with a tunnelConfiguration
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuardNetworkExtension')
-rw-r--r-- | WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift index e131e74..cae4524 100644 --- a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift +++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift @@ -23,7 +23,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider { /// Begin the process of establishing the tunnel. override func startTunnel(options: [String: NSObject]?, completionHandler startTunnelCompletionHandler: @escaping (Error?) -> Void) { - os_log("Starting tunnel", log: OSLog.default, type: .info) guard let tunnelProviderProtocol = self.protocolConfiguration as? NETunnelProviderProtocol, let tunnelConfiguration = tunnelProviderProtocol.tunnelConfiguration() else { @@ -32,6 +31,12 @@ class PacketTunnelProvider: NEPacketTunnelProvider { return } + startTunnel(with: tunnelConfiguration, completionHandler: startTunnelCompletionHandler) + } + + func startTunnel(with tunnelConfiguration: TunnelConfiguration, completionHandler startTunnelCompletionHandler: @escaping (Error?) -> Void) { + os_log("Starting tunnel", log: OSLog.default, type: .info) + // Resolve endpoint domains let endpoints = tunnelConfiguration.peers.map { $0.endpoint } |