aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-03-11 13:20:21 +0530
committerRoopesh Chander <roop@roopc.net>2019-03-11 13:20:21 +0530
commit663923864cb2354a88deca85ca3c5aaaf8972226 (patch)
treef5b4d765ad7f2f5f784fdff2390f98e6cb5d006b
parentmacOS: Ability to remove multiple tunnels at a time (diff)
downloadwireguard-apple-663923864cb2354a88deca85ca3c5aaaf8972226.tar.xz
wireguard-apple-663923864cb2354a88deca85ca3c5aaaf8972226.zip
TunnelsManager: Don't restart if only on-demand setting has changed
Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r--WireGuard/WireGuard/Tunnel/TunnelsManager.swift16
1 files changed, 11 insertions, 5 deletions
diff --git a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
index 3f7d9f5..ea5e622 100644
--- a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
+++ b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
@@ -184,7 +184,11 @@ class TunnelsManager {
tunnel.name = tunnelName
}
- tunnelProviderManager.setTunnelConfiguration(tunnelConfiguration)
+ var isTunnelConfigurationChanged = false
+ if tunnelProviderManager.tunnelConfiguration != tunnelConfiguration {
+ tunnelProviderManager.setTunnelConfiguration(tunnelConfiguration)
+ isTunnelConfigurationChanged = true
+ }
tunnelProviderManager.isEnabled = true
let isActivatingOnDemand = !tunnelProviderManager.isOnDemandEnabled && activateOnDemandSetting.isActivateOnDemandEnabled
@@ -206,10 +210,12 @@ class TunnelsManager {
}
self.tunnelsListDelegate?.tunnelModified(at: self.tunnels.firstIndex(of: tunnel)!)
- 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 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 {