]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
WireGuardKit: Let wireguard-go backend run in offline on macOS
authorAndrej Mihajlov <and@mullvad.net>
Fri, 11 Dec 2020 10:49:56 +0000 (11:49 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 11 Dec 2020 10:56:05 +0000 (11:56 +0100)
Signed-off-by: Andrej Mihajlov <and@mullvad.net>
Sources/WireGuardKit/WireGuardAdapter.swift

index bf885c2ab91b81a8eb0ebe30c3afba64c1101681..f2e4040aa3f605f3b6b88306616a8d006f5d7035 100644 (file)
@@ -386,16 +386,18 @@ public class WireGuardAdapter {
     private func didReceivePathUpdate(path: Network.NWPath) {
         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 {
         case .started(let handle, let settingsGenerator):
             if path.status.isSatisfiable {
-                #if os(iOS)
                 let (wgConfig, resolutionResults) = settingsGenerator.endpointUapiConfiguration()
                 self.logEndpointResolutionResults(resolutionResults)
 
                 wgSetConfig(handle, wgConfig)
-                #endif
-
                 wgBumpSockets(handle)
             } else {
                 self.logHandler(.info, "Connectivity offline, pausing backend.")
@@ -427,6 +429,9 @@ public class WireGuardAdapter {
             // no-op
             break
         }
+        #else
+        #error("Unsupported")
+        #endif
     }
 }