aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/VPN/TunnelsManager.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-12-11 01:58:40 +0530
committerRoopesh Chander <roop@roopc.net>2018-12-11 02:42:21 +0530
commite59dbe63645cfea5be82a4e3f2b0c3e3996f9999 (patch)
tree1698d89f31fe8b5458701a47bb3130f49ab65882 /WireGuard/WireGuard/VPN/TunnelsManager.swift
parentAllow turning off the status switch of a waiting tunnel (diff)
downloadwireguard-apple-e59dbe63645cfea5be82a4e3f2b0c3e3996f9999.tar.xz
wireguard-apple-e59dbe63645cfea5be82a4e3f2b0c3e3996f9999.zip
TunnelsManager: Deactivate only when the status becomes 'connected'
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/VPN/TunnelsManager.swift14
1 files changed, 11 insertions, 3 deletions
diff --git a/WireGuard/WireGuard/VPN/TunnelsManager.swift b/WireGuard/WireGuard/VPN/TunnelsManager.swift
index 7c4fe9a..8003208 100644
--- a/WireGuard/WireGuard/VPN/TunnelsManager.swift
+++ b/WireGuard/WireGuard/VPN/TunnelsManager.swift
@@ -260,7 +260,7 @@ class TunnelsManager {
tunnelWaitingForActivation = (tunnel, completionHandler)
os_log("Tunnel '%{public}@' is waiting for deactivation of '%{public}@' (status: %{public}@)",
log: OSLog.default, type: .debug, tunnel.name, tunnelInOperation.name, "\(tunnelInOperation.status)")
- if (tunnelInOperation.status != .deactivating) {
+ if (tunnelInOperation.status == .active) {
tunnelBeingActivated = nil
startDeactivation(of: tunnelInOperation)
}
@@ -301,6 +301,9 @@ class TunnelsManager {
guard let tunnel = self?.tunnels.first(where: { $0.tunnelProvider == tunnelProvider }) else { return }
guard let s = self else { return }
+ os_log("Tunnel '%{public}@' connection status changed to '%{public}@'",
+ log: OSLog.default, type: .debug, tunnel.name, "\(tunnel.tunnelProvider.connection.status)")
+
// In case our attempt to start the tunnel, didn't succeed
if (tunnel == s.tunnelBeingActivated) {
if (session.status == .disconnected) {
@@ -328,8 +331,13 @@ class TunnelsManager {
tunnel.refreshStatus()
// In case some other tunnel is waiting on this tunnel's deactivation
- if (tunnel.status == .inactive) {
- if let (waitingTunnel, waitingTunnelCompletionHandler) = s.tunnelWaitingForActivation {
+
+ if let (waitingTunnel, waitingTunnelCompletionHandler) = s.tunnelWaitingForActivation {
+ if (tunnel.status == .active) {
+ os_log("Deactivating tunnel '%{public}@' because tunnel '%{public}@' is waiting for activation",
+ log: OSLog.default, type: .debug, tunnel.name, waitingTunnel.name)
+ tunnel.startDeactivation()
+ } else if (tunnel.status == .inactive) {
os_log("Activating waiting tunnel '%{public}@' after deactivation of '%{public}@'",
log: OSLog.default, type: .debug, waitingTunnel.name, tunnel.name)
precondition(waitingTunnel.status == .waiting)