From: Roopesh Chander Date: Tue, 27 Jul 2021 06:09:07 +0000 (+0530) Subject: UI: When deactivating for activating another tunnel, disable on-demand X-Git-Tag: 1.0.14-25~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a261d84fc62ba5e0b7a33ba6eaf7d379c1bdd200;p=thirdparty%2Fwireguard-apple.git UI: When deactivating for activating another tunnel, disable on-demand Signed-off-by: Roopesh Chander --- 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 }