From 3bf340c74c48bdf88c19859d8e5f213157a23d51 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 19 Mar 2019 17:57:51 +0100 Subject: [PATCH] Prepare before disconnection intent manager is nil otherwise in connect/disconnect. Doesn't apply to reinstall/reconnect. --- Passepartout/Sources/Intents/IntentDispatcher.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Passepartout/Sources/Intents/IntentDispatcher.swift b/Passepartout/Sources/Intents/IntentDispatcher.swift index c050d0be..a611e311 100644 --- a/Passepartout/Sources/Intents/IntentDispatcher.swift +++ b/Passepartout/Sources/Intents/IntentDispatcher.swift @@ -200,9 +200,13 @@ public class IntentDispatcher { public static func handleDisableVPN(_ intent: DisableVPNIntent, interaction: INInteraction?, completionHandler: ((Error?) -> Void)?) { log.info("Disabling VPN...") - VPN.shared.disconnect { (error) in - notifyServiceUpdate() - completionHandler?(error) + + let vpn = VPN.shared + vpn.prepare { + vpn.disconnect { (error) in + notifyServiceUpdate() + completionHandler?(error) + } } }