aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuardNetworkExtension/PacketTunnelProvider.swift
diff options
context:
space:
mode:
authorJeroen Leenarts <jeroen.leenarts@gmail.com>2018-08-08 07:04:42 +0200
committerJeroen Leenarts <jeroen.leenarts@gmail.com>2018-08-08 07:04:42 +0200
commitbee5363dfae7b96ef998e6b193eb4768a18e3fe1 (patch)
tree2b9e9595187905a5c9ab7fdb2aca4c4aa3f5011d /WireGuardNetworkExtension/PacketTunnelProvider.swift
parentAdd tunnel provider identifier. (diff)
downloadwireguard-apple-bee5363dfae7b96ef998e6b193eb4768a18e3fe1.tar.xz
wireguard-apple-bee5363dfae7b96ef998e6b193eb4768a18e3fe1.zip
Switch from using a single VPN manager to a VPN manager per configuration.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--WireGuardNetworkExtension/PacketTunnelProvider.swift9
1 files changed, 5 insertions, 4 deletions
diff --git a/WireGuardNetworkExtension/PacketTunnelProvider.swift b/WireGuardNetworkExtension/PacketTunnelProvider.swift
index 3cf2730..a6891fa 100644
--- a/WireGuardNetworkExtension/PacketTunnelProvider.swift
+++ b/WireGuardNetworkExtension/PacketTunnelProvider.swift
@@ -27,11 +27,12 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
override func startTunnel(options: [String: NSObject]?, completionHandler: @escaping (Error?) -> Void) {
os_log("Starting tunnel", log: Log.general, type: .info)
- //TODO tunnel settings
- if wireGuardWrapper.turnOn(withInterfaceName: "test", settingsString: "") {
- // Success
-// completionHandler(nil)
+ let config = self.protocolConfiguration as! NETunnelProviderProtocol // swiftlint:disable:this force_cast
+ let interfaceName = config.providerConfiguration!["title"]! as! String // swiftlint:disable:this force_cast
+ let settings = config.providerConfiguration!["settings"]! as! String // swiftlint:disable:this force_cast
+ if wireGuardWrapper.turnOn(withInterfaceName: interfaceName, settingsString: settings) {
+ // Success
//TODO obtain network config from WireGuard config or remote.
// route all traffic to VPN
let defaultRoute = NEIPv4Route.default()