UI: When deactivating for activating another tunnel, disable on-demand

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2021-07-27 11:39:07 +05:30
parent abaf1f1454
commit a261d84fc6
1 changed files with 11 additions and 1 deletions

View File

@ -419,8 +419,18 @@ class TunnelsManager {
tunnel.status = .waiting tunnel.status = .waiting
activateWaitingTunnelOnDeactivation(of: tunnelInOperation) activateWaitingTunnelOnDeactivation(of: tunnelInOperation)
if tunnelInOperation.status != .deactivating { if tunnelInOperation.status != .deactivating {
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) startDeactivation(of: tunnelInOperation)
} }
}
return return
} }