TunnelsManager: Don't restart if only on-demand setting has changed

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2019-03-11 13:20:21 +05:30
parent 9250780ffc
commit 663923864c
1 changed files with 11 additions and 5 deletions

View File

@ -184,7 +184,11 @@ class TunnelsManager {
tunnel.name = tunnelName
}
var isTunnelConfigurationChanged = false
if tunnelProviderManager.tunnelConfiguration != tunnelConfiguration {
tunnelProviderManager.setTunnelConfiguration(tunnelConfiguration)
isTunnelConfigurationChanged = true
}
tunnelProviderManager.isEnabled = true
let isActivatingOnDemand = !tunnelProviderManager.isOnDemandEnabled && activateOnDemandSetting.isActivateOnDemandEnabled
@ -206,11 +210,13 @@ class TunnelsManager {
}
self.tunnelsListDelegate?.tunnelModified(at: self.tunnels.firstIndex(of: tunnel)!)
if isTunnelConfigurationChanged {
if tunnel.status == .active || tunnel.status == .activating || tunnel.status == .reasserting {
// Turn off the tunnel, and then turn it back on, so the changes are made effective
tunnel.status = .restarting
(tunnel.tunnelProvider.connection as? NETunnelProviderSession)?.stopTunnel()
}
}
if isActivatingOnDemand {
// Reload tunnel after saving.