diff options
author | Roopesh Chander <roop@roopc.net> | 2021-07-27 11:39:07 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2021-07-28 03:35:05 +0530 |
commit | a261d84fc62ba5e0b7a33ba6eaf7d379c1bdd200 (patch) | |
tree | ce19f4edc479f7efacc8761f6b17f5496e9a7840 /Sources/WireGuardApp | |
parent | UI: Keep on-demand rules even if on-demand is disabled (diff) | |
download | wireguard-apple-a261d84fc62ba5e0b7a33ba6eaf7d379c1bdd200.tar.xz wireguard-apple-a261d84fc62ba5e0b7a33ba6eaf7d379c1bdd200.zip |
UI: When deactivating for activating another tunnel, disable on-demand
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'Sources/WireGuardApp')
-rw-r--r-- | Sources/WireGuardApp/Tunnel/TunnelsManager.swift | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Sources/WireGuardApp/Tunnel/TunnelsManager.swift b/Sources/WireGuardApp/Tunnel/TunnelsManager.swift index 8eda2cb..e1a9a39 100644 --- a/Sources/WireGuardApp/Tunnel/TunnelsManager.swift +++ b/Sources/WireGuardApp/Tunnel/TunnelsManager.swift @@ -419,7 +419,17 @@ class TunnelsManager { tunnel.status = .waiting activateWaitingTunnelOnDeactivation(of: tunnelInOperation) if tunnelInOperation.status != .deactivating { - startDeactivation(of: tunnelInOperation) + if tunnelInOperation.isActivateOnDemandEnabled { + setOnDemandEnabled(false, on: tunnelInOperation) { [weak self] error in + guard error == nil else { + wg_log(.error, message: "Unable to activate tunnel '\(tunnel.name)' because on-demand could not be disabled on active tunnel '\(tunnel.name)'") + return + } + self?.startDeactivation(of: tunnelInOperation) + } + } else { + startDeactivation(of: tunnelInOperation) + } } return } |