mirror of
https://github.com/passepartoutvpn/wireguard-apple.git
synced 2025-02-27 18:22:12 +00:00
NE: Minor refactoring to enable calling startTunnel() with a tunnelConfiguration
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
1d63509b92
commit
7485474c4c
@ -23,7 +23,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||||||
/// Begin the process of establishing the tunnel.
|
/// Begin the process of establishing the tunnel.
|
||||||
override func startTunnel(options: [String: NSObject]?,
|
override func startTunnel(options: [String: NSObject]?,
|
||||||
completionHandler startTunnelCompletionHandler: @escaping (Error?) -> Void) {
|
completionHandler startTunnelCompletionHandler: @escaping (Error?) -> Void) {
|
||||||
os_log("Starting tunnel", log: OSLog.default, type: .info)
|
|
||||||
|
|
||||||
guard let tunnelProviderProtocol = self.protocolConfiguration as? NETunnelProviderProtocol,
|
guard let tunnelProviderProtocol = self.protocolConfiguration as? NETunnelProviderProtocol,
|
||||||
let tunnelConfiguration = tunnelProviderProtocol.tunnelConfiguration() else {
|
let tunnelConfiguration = tunnelProviderProtocol.tunnelConfiguration() else {
|
||||||
@ -32,6 +31,12 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||||||
return
|
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
|
// Resolve endpoint domains
|
||||||
|
|
||||||
let endpoints = tunnelConfiguration.peers.map { $0.endpoint }
|
let endpoints = tunnelConfiguration.peers.map { $0.endpoint }
|
||||||
|
Loading…
Reference in New Issue
Block a user