diff options
author | Roopesh Chander <roop@roopc.net> | 2021-09-24 00:41:46 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2021-09-24 01:01:10 +0530 |
commit | ba644415c7ff925e34bbabd2448e41c49924b2fa (patch) | |
tree | 9392f9456b8cbed85aca96c96bbfd441ad065d28 /Sources/WireGuardApp/Tunnel/ActivateOnDemandOption.swift | |
parent | App: version bump (diff) | |
download | wireguard-apple-ba644415c7ff925e34bbabd2448e41c49924b2fa.tar.xz wireguard-apple-ba644415c7ff925e34bbabd2448e41c49924b2fa.zip |
UI: When saving on-demand rules on a config, enable on-demand if active
When a user saves on-demand rules on the configuration, set
onDemandEnabled to true if the tunnel is active, and false if it isn't.
Then deactivate the tunnel.
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'Sources/WireGuardApp/Tunnel/ActivateOnDemandOption.swift')
-rw-r--r-- | Sources/WireGuardApp/Tunnel/ActivateOnDemandOption.swift | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Sources/WireGuardApp/Tunnel/ActivateOnDemandOption.swift b/Sources/WireGuardApp/Tunnel/ActivateOnDemandOption.swift index b92ada7..9ba605a 100644 --- a/Sources/WireGuardApp/Tunnel/ActivateOnDemandOption.swift +++ b/Sources/WireGuardApp/Tunnel/ActivateOnDemandOption.swift @@ -42,7 +42,9 @@ extension ActivateOnDemandOption { } } tunnelProviderManager.onDemandRules = rules - tunnelProviderManager.isOnDemandEnabled = false + let status = tunnelProviderManager.connection.status + let isActive = status == .connected || status == .connecting + tunnelProviderManager.isOnDemandEnabled = (rules != nil) && (tunnelProviderManager.isOnDemandEnabled || isActive) } init(from tunnelProviderManager: NETunnelProviderManager) { |