]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
Kit: Adapter: do not treat NE settings timeouts as fatal
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 16 Dec 2020 23:24:39 +0000 (00:24 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 16 Dec 2020 23:26:00 +0000 (00:26 +0100)
The general Network Extension framework is incredibly buggy, and a
timeout when setting the network settings does not necessarily imply
that the whole operation failed. Simply log the condition and move on.
This restores the app's old behavior.

Reported-by: Filipe Mendonça <cfilipem@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Sources/WireGuardKit/WireGuardAdapter.swift
Sources/WireGuardNetworkExtension/PacketTunnelProvider.swift

index 6c2e956670471c8ac855dc69bd7f35967ff8f187..16e1b283ccac6b48f4b0021df115b76944ed23df 100644 (file)
@@ -21,9 +21,6 @@ public enum WireGuardAdapterError: Error {
     /// Failure to set network settings.
     case setNetworkSettings(Error)
 
-    /// Timeout when calling to set network settings.
-    case setNetworkSettingsTimeout
-
     /// Failure to start WireGuard backend.
     case startWireGuardBackend(Int32)
 }
@@ -304,7 +301,7 @@ public class WireGuardAdapter {
                 throw WireGuardAdapterError.setNetworkSettings(systemError)
             }
         } else {
-            throw WireGuardAdapterError.setNetworkSettingsTimeout
+            self.logHandler(.error, "setTunnelNetworkSettings timed out after 5 seconds; proceeding anyway")
         }
     }
 
index 042d86c3f55971389bc5584272d73fd8a1b48dc8..5ba82229ff615f9e97b70500a5f40adb0c5d7c35 100644 (file)
@@ -57,11 +57,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
                 errorNotifier.notify(PacketTunnelProviderError.couldNotSetNetworkSettings)
                 completionHandler(PacketTunnelProviderError.couldNotSetNetworkSettings)
 
-            case .setNetworkSettingsTimeout:
-                wg_log(.error, message: "Starting tunnel failed with setTunnelNetworkSettings timing out")
-                errorNotifier.notify(PacketTunnelProviderError.couldNotSetNetworkSettings)
-                completionHandler(PacketTunnelProviderError.couldNotSetNetworkSettings)
-
             case .startWireGuardBackend(let errorCode):
                 wg_log(.error, message: "Starting tunnel failed with wgTurnOn returning \(errorCode)")
                 errorNotifier.notify(PacketTunnelProviderError.couldNotStartBackend)