From db4e2915f33aa561fff2401e05319e1b5241fdf8 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 17 Dec 2020 00:24:39 +0100 Subject: [PATCH] Kit: Adapter: do not treat NE settings timeouts as fatal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Jason A. Donenfeld --- Sources/WireGuardKit/WireGuardAdapter.swift | 5 +---- Sources/WireGuardNetworkExtension/PacketTunnelProvider.swift | 5 ----- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Sources/WireGuardKit/WireGuardAdapter.swift b/Sources/WireGuardKit/WireGuardAdapter.swift index 6c2e956..16e1b28 100644 --- a/Sources/WireGuardKit/WireGuardAdapter.swift +++ b/Sources/WireGuardKit/WireGuardAdapter.swift @@ -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") } } diff --git a/Sources/WireGuardNetworkExtension/PacketTunnelProvider.swift b/Sources/WireGuardNetworkExtension/PacketTunnelProvider.swift index 042d86c..5ba8222 100644 --- a/Sources/WireGuardNetworkExtension/PacketTunnelProvider.swift +++ b/Sources/WireGuardNetworkExtension/PacketTunnelProvider.swift @@ -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)