]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
TunnelsManager: Always call the completion handler before returning
authorRoopesh Chander <roop@roopc.net>
Mon, 10 Dec 2018 11:30:31 +0000 (17:00 +0530)
committerRoopesh Chander <roop@roopc.net>
Mon, 10 Dec 2018 11:31:53 +0000 (17:01 +0530)
Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/WireGuard/VPN/TunnelsManager.swift

index c8c2b2a9c7945401f056548db1bfd857ceaf39cf..d3f711a2ad603d84cbbe539758bf8923c869c750 100644 (file)
@@ -26,6 +26,7 @@ enum TunnelsManagerError: WireGuardAppError {
     case vpnSystemErrorOnRemoveTunnel
 
     // Tunnel activation
+    case attemptingActivationWhenTunnelIsNotInactive
     case tunnelActivationAttemptFailed // startTunnel() throwed
     case tunnelActivationFailedInternalError // startTunnel() succeeded, but activation failed
     case tunnelActivationFailedNoInternetConnection // startTunnel() succeeded, but activation failed since no internet
@@ -45,6 +46,8 @@ enum TunnelsManagerError: WireGuardAppError {
         case .vpnSystemErrorOnRemoveTunnel:
             return ("Unable to remove tunnel", "Internal error")
 
+        case .attemptingActivationWhenTunnelIsNotInactive:
+            return ("Activation failure", "The tunnel is already active or in the process of being activated")
         case .tunnelActivationAttemptFailed:
             return ("Activation failure", "The tunnel could not be activated due to an internal error")
         case .tunnelActivationFailedInternalError:
@@ -232,6 +235,7 @@ class TunnelsManager {
 
     func startActivation(of tunnel: TunnelContainer, completionHandler: @escaping (TunnelsManagerError?) -> Void) {
         guard (tunnel.status == .inactive) else {
+            completionHandler(TunnelsManagerError.attemptingActivationWhenTunnelIsNotInactive)
             return
         }