From b491b9c37188e6fde7972f3f971652891de2228a Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Mon, 10 Dec 2018 16:28:41 +0530 Subject: [PATCH] TunnelsManager: Handle deactivation of a waiting tunnel Signed-off-by: Roopesh Chander --- WireGuard/WireGuard/VPN/TunnelsManager.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/WireGuard/WireGuard/VPN/TunnelsManager.swift b/WireGuard/WireGuard/VPN/TunnelsManager.swift index 2276ef7..b0db3c0 100644 --- a/WireGuard/WireGuard/VPN/TunnelsManager.swift +++ b/WireGuard/WireGuard/VPN/TunnelsManager.swift @@ -402,8 +402,13 @@ class TunnelContainer: NSObject { } fileprivate func startDeactivation() { - assert(status == .active || status == .waiting) let session = (tunnelProvider.connection as! NETunnelProviderSession) + if (status == .waiting && (session.status == .disconnected || session.status == .invalid)) { + status = .inactive + self.onDeactivationComplete?() + self.onDeactivationComplete = nil + return + } session.stopTunnel() }