If the selected tunnel is not "enabled", make it enabled.

This commit is contained in:
Jeroen Leenarts 2018-08-16 22:05:22 +02:00
parent 11b43206ff
commit 792301e50e
1 changed files with 14 additions and 5 deletions

View File

@ -166,6 +166,14 @@ extension AppCoordinator: TunnelsTableViewControllerDelegate {
// Should the manager be enabled? // Should the manager be enabled?
let manager = providerManager(for: tunnel) let manager = providerManager(for: tunnel)
manager?.isEnabled = true
manager?.saveToPreferences { (error) in
if let error = error {
os_log("error saving preferences: %{public}@", log: Log.general, type: .error, error.localizedDescription)
return
}
os_log("saved preferences", log: Log.general, type: .info)
let session = manager?.connection as! NETunnelProviderSession //swiftlint:disable:this force_cast let session = manager?.connection as! NETunnelProviderSession //swiftlint:disable:this force_cast
do { do {
try session.startTunnel() try session.startTunnel()
@ -173,6 +181,7 @@ extension AppCoordinator: TunnelsTableViewControllerDelegate {
os_log("error starting tunnel: %{public}@", log: Log.general, type: .error, error.localizedDescription) os_log("error starting tunnel: %{public}@", log: Log.general, type: .error, error.localizedDescription)
} }
} }
}
func disconnect(tunnel: Tunnel) { func disconnect(tunnel: Tunnel) {
let manager = providerManager(for: tunnel) let manager = providerManager(for: tunnel)