]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
PacketTunnelProvider: proper fix for 32073323
authorJason A. Donenfeld <Jason@zx2c4.com>
Thu, 7 Feb 2019 14:01:37 +0000 (15:01 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Thu, 7 Feb 2019 14:01:37 +0000 (15:01 +0100)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
WireGuard/WireGuard/Tunnel/TunnelsManager.swift
WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift

index a2fc00b98ef2544d4ffe5a32419d97029f9f4648..f0ba84a1de999c94f8ae1fdc15c3eeaa9cba2da8 100644 (file)
@@ -442,21 +442,6 @@ class TunnelContainer: NSObject {
     }
 
     func refreshStatus() {
-        #if os(macOS)
-        // In macOS, we wait for a few seconds after deactivation to work around a system bug.
-        // If a tunnel gets activated in this time interval, it's stopped by the system automatically in ~25 seconds.
-        if self.status == .deactivating && tunnelProvider.connection.status == .disconnected {
-            self.deactivationTimer?.invalidate()
-            let deactivationTimer = Timer(timeInterval: 6 /* seconds */, repeats: false) { [weak self] _ in
-                guard let self = self else { return }
-                self.status = TunnelStatus(from: self.tunnelProvider.connection.status)
-                self.isActivateOnDemandEnabled = self.tunnelProvider.isOnDemandEnabled
-            }
-            self.deactivationTimer = deactivationTimer
-            RunLoop.main.add(deactivationTimer, forMode: .common)
-            return
-        }
-        #endif
         status = TunnelStatus(from: tunnelProvider.connection.status)
         isActivateOnDemandEnabled = tunnelProvider.isOnDemandEnabled
     }
index 5ac6b282096d5b0a21aa57f21b99a93269967549..8b96bae5788f6f2fac516dae5c6e0e309037d6ef 100644 (file)
@@ -95,6 +95,13 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
             wgTurnOff(handle)
         }
         completionHandler()
+
+        #if os(macOS)
+        // HACK: This is a filthy hack to work around Apple bug 32073323 (dup'd by us as 47526107).
+        // Remove it when they finally fix this upstream and the fix has been rolled out to
+        // sufficient quantities of users.
+        exit(0)
+        #endif
     }
 
     override func handleAppMessage(_ messageData: Data, completionHandler: ((Data?) -> Void)? = nil) {