Switch from using a single VPN manager to a VPN manager per configuration.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jeroen Leenarts
2018-08-08 07:04:42 +02:00
parent 2b7aa04d40
commit bee5363dfa
3 changed files with 79 additions and 135 deletions
@@ -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()