aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-12-20 16:38:17 +0100
committerAndrej Mihajlov <and@mullvad.net>2021-12-20 16:38:17 +0100
commit9f63c014117fd660f080e8568d2dc3e0d45dc820 (patch)
treee3b6536b98ea2ab94489f662a4772c188b65e3d3
parentUI: When saving on-demand rules, deactivate if reqd and then save (diff)
downloadwireguard-apple-am/ignore-set-network-settings-error-when-offline-alternative.tar.xz
wireguard-apple-am/ignore-set-network-settings-error-when-offline-alternative.zip
Kit: Adapter: ignore error when updating tunnel settings in offlineam/ignore-set-network-settings-error-when-offline-alternative
Since around iOS 15.1, calling `setNetworkSettings()` when in airplane mode, throws an unknown error: Error Domain=NEAgentErrorDomain Code=1 Signed-off-by: Andrej Mihajlov <and@mullvad.net>
-rw-r--r--Sources/WireGuardKit/WireGuardAdapter.swift8
1 files changed, 7 insertions, 1 deletions
diff --git a/Sources/WireGuardKit/WireGuardAdapter.swift b/Sources/WireGuardKit/WireGuardAdapter.swift
index 4cb2e2e..9feaccd 100644
--- a/Sources/WireGuardKit/WireGuardAdapter.swift
+++ b/Sources/WireGuardKit/WireGuardAdapter.swift
@@ -255,10 +255,11 @@ public class WireGuardAdapter {
do {
let settingsGenerator = try self.makeSettingsGenerator(with: tunnelConfiguration)
- try self.setNetworkSettings(settingsGenerator.generateNetworkSettings())
switch self.state {
case .started(let handle, _):
+ try self.setNetworkSettings(settingsGenerator.generateNetworkSettings())
+
let (wgConfig, resolutionResults) = settingsGenerator.uapiConfiguration()
self.logEndpointResolutionResults(resolutionResults)
@@ -270,6 +271,11 @@ public class WireGuardAdapter {
self.state = .started(handle, settingsGenerator)
case .temporaryShutdown:
+ // On iOS 15.1 or newer, updating network settings may fail when in airplane mode.
+ // Network path monitor will retry updating settings later when connectivity is
+ // back online.
+ try? self.setNetworkSettings(settingsGenerator.generateNetworkSettings())
+
self.state = .temporaryShutdown(settingsGenerator)
case .stopped: