aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-06-08 22:35:09 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-06-09 11:39:06 +0200
commit002345ca254b91081a6a9b9c4c96d080a5458189 (patch)
treedbcc976aa858aee3ebb079307d2aed4c0ee42ff3
parentREADME: update repo location (diff)
downloadwireguard-apple-002345ca254b91081a6a9b9c4c96d080a5458189.tar.xz
wireguard-apple-002345ca254b91081a6a9b9c4c96d080a5458189.zip
TunnelProvider: store the entire NWPath
Otherwise [utun0, en0] == [en0, utun0] before WiFi has connected, and we wind up not rebinding after WiFi does successfully connect, which means people have trouble when resuming from sleep.
-rw-r--r--WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift9
1 files changed, 3 insertions, 6 deletions
diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
index 0618b19e..2ecd610c 100644
--- a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
+++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
@@ -11,7 +11,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
private var handle: Int32?
private var networkMonitor: NWPathMonitor?
private var ifname: String?
- private var lastSeenInterfaces: [String] = []
+ private var lastPath: Network.NWPath?
private var packetTunnelSettingsGenerator: PacketTunnelSettingsGenerator?
deinit {
@@ -143,18 +143,15 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
private func pathUpdate(path: Network.NWPath) {
guard let handle = handle else { return }
- guard let ifname = ifname else { return }
wg_log(.debug, message: "Network change detected with \(path.status) route and interface order \(path.availableInterfaces)")
- guard path.status == .satisfied else { return }
#if os(iOS)
if let packetTunnelSettingsGenerator = packetTunnelSettingsGenerator {
_ = packetTunnelSettingsGenerator.endpointUapiConfiguration().withGoString { return wgSetConfig(handle, $0) }
}
#endif
- let interfaces = path.availableInterfaces.filter { $0.name != ifname }.compactMap { $0.name }
- if !interfaces.elementsEqual(lastSeenInterfaces) {
- lastSeenInterfaces = interfaces
+ if path != lastPath {
+ lastPath = path
wgBumpSockets(handle)
}
}