WireGuardKit: Let wireguard-go backend run in offline on macOS
Signed-off-by: Andrej Mihajlov <and@mullvad.net>
This commit is contained in:
parent
54e3333b72
commit
d414cec9aa
|
@ -386,16 +386,18 @@ public class WireGuardAdapter {
|
||||||
private func didReceivePathUpdate(path: Network.NWPath) {
|
private func didReceivePathUpdate(path: Network.NWPath) {
|
||||||
self.logHandler(.debug, "Network change detected with \(path.status) route and interface order \(path.availableInterfaces)")
|
self.logHandler(.debug, "Network change detected with \(path.status) route and interface order \(path.availableInterfaces)")
|
||||||
|
|
||||||
|
#if os(macOS)
|
||||||
|
if case .started(let handle, _) = self.state {
|
||||||
|
wgBumpSockets(handle)
|
||||||
|
}
|
||||||
|
#elseif os(iOS)
|
||||||
switch self.state {
|
switch self.state {
|
||||||
case .started(let handle, let settingsGenerator):
|
case .started(let handle, let settingsGenerator):
|
||||||
if path.status.isSatisfiable {
|
if path.status.isSatisfiable {
|
||||||
#if os(iOS)
|
|
||||||
let (wgConfig, resolutionResults) = settingsGenerator.endpointUapiConfiguration()
|
let (wgConfig, resolutionResults) = settingsGenerator.endpointUapiConfiguration()
|
||||||
self.logEndpointResolutionResults(resolutionResults)
|
self.logEndpointResolutionResults(resolutionResults)
|
||||||
|
|
||||||
wgSetConfig(handle, wgConfig)
|
wgSetConfig(handle, wgConfig)
|
||||||
#endif
|
|
||||||
|
|
||||||
wgBumpSockets(handle)
|
wgBumpSockets(handle)
|
||||||
} else {
|
} else {
|
||||||
self.logHandler(.info, "Connectivity offline, pausing backend.")
|
self.logHandler(.info, "Connectivity offline, pausing backend.")
|
||||||
|
@ -427,6 +429,9 @@ public class WireGuardAdapter {
|
||||||
// no-op
|
// no-op
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#error("Unsupported")
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue