]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
macOS: remove mobile network tweeks
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 22 Jan 2019 12:09:38 +0000 (13:09 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 22 Jan 2019 12:11:28 +0000 (13:11 +0100)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
WireGuard/WireGuardNetworkExtension/DNSResolver.swift
WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
wireguard-go-bridge/src/api-ios.go
wireguard-go-bridge/wireguard.h

index f7a8f5b1469e97febb6715d0aef59f1aeb48731f..16b79093876f39591dd110906cdc97f624f6eda6 100644 (file)
@@ -107,6 +107,7 @@ class DNSResolver {
 
 extension Endpoint {
     func withReresolvedIP() -> Endpoint {
+        #if os(iOS)
         var ret = self
         let hostname: String
         switch host {
@@ -148,5 +149,10 @@ extension Endpoint {
             wg_log(.debug, message: "DNS64: mapped \(host) to itself.")
         }
         return ret
+        #elseif os(macOS)
+        return self
+        #else
+        #error("Unimplemented")
+        #endif
     }
 }
index cfc3aedf5e4cedcef5c8752bcf9daabeb0b69c80..7c84491af2fd6595ae06eb809a5ed8edb2838214 100644 (file)
@@ -30,6 +30,9 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
         }
 
         configureLogger()
+        #if os(macOS)
+        wgEnableRoaming(true)
+        #endif
 
         wg_log(.info, message: "Starting tunnel from the " + (activationAttemptId == nil ? "OS directly, rather than the app" : "app"))
 
@@ -114,9 +117,13 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
     }
 
     private func pathUpdate(path: Network.NWPath) {
-        guard let handle = handle, let packetTunnelSettingsGenerator = packetTunnelSettingsGenerator else { return }
+        guard let handle = handle else { return }
         wg_log(.debug, message: "Network change detected with \(path.status) route and interface order \(path.availableInterfaces)")
-        _ = packetTunnelSettingsGenerator.endpointUapiConfiguration().withGoString { return wgSetConfig(handle, $0) }
+        #if os(iOS)
+        if let packetTunnelSettingsGenerator = packetTunnelSettingsGenerator {
+            _ = packetTunnelSettingsGenerator.endpointUapiConfiguration().withGoString { return wgSetConfig(handle, $0) }
+        }
+        #endif
         var interfaces = path.availableInterfaces
         if let ifname = ifname {
             interfaces = interfaces.filter { $0.name != ifname }
index 94a2cd03cda8b243b464cebab5e67a9c2fef6806..ace83d9b3e6f11ab4170dcc174583ed3fbaf4519 100644 (file)
@@ -68,6 +68,11 @@ func init() {
        }()
 }
 
+//export wgEnableRoaming
+func wgEnableRoaming(enabled bool) {
+       roamingDisabled = !enabled
+}
+
 //export wgSetLogger
 func wgSetLogger(loggerFn uintptr) {
        loggerFunc = unsafe.Pointer(loggerFn)
index 500f1381b2ed5faef37f76f28f1bc58952e70dee..b264a2efaf4607d42559979eca77133543b9f567 100644 (file)
@@ -8,9 +8,11 @@
 
 #include <sys/types.h>
 #include <stdint.h>
+#include <stdbool.h>
 
 typedef struct { const char *p; size_t n; } gostring_t;
 typedef void(*logger_fn_t)(int level, const char *msg);
+extern void wgEnableRoaming(bool enabled);
 extern void wgSetLogger(logger_fn_t logger_fn);
 extern int wgTurnOn(gostring_t settings, int32_t tun_fd);
 extern void wgTurnOff(int handle);