]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
NE: Minor refactoring to enable calling startTunnel() with a tunnelConfiguration
authorRoopesh Chander <roop@roopc.net>
Fri, 9 Nov 2018 14:19:48 +0000 (19:49 +0530)
committerRoopesh Chander <roop@roopc.net>
Fri, 9 Nov 2018 16:59:52 +0000 (22:29 +0530)
Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift

index e131e74ef9a1c261337f394f361d80f38109542c..cae452458a9235cc0de8778b0e29293285c42350 100644 (file)
@@ -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 }