aboutsummaryrefslogtreecommitdiffstats
path: root/Sources/WireGuardApp/Tunnel/TunnelsManager.swift
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Sources/WireGuardApp/Tunnel/TunnelsManager.swift12
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
}