NE: Minor refactoring to enable calling startTunnel() with a tunnelConfiguration

This commit is contained in:
Roopesh Chander 2018-11-09 19:49:48 +05:30
parent 9568c7f980
commit 6d28240531
1 changed files with 6 additions and 1 deletions

View 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 }