Kit: Adapter: do not treat NE settings timeouts as fatal

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>
This commit is contained in:
Jason A. Donenfeld 2020-12-17 00:24:39 +01:00
parent 20bdf46792
commit db4e2915f3
2 changed files with 1 additions and 9 deletions

View 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")
}
}

View 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)