]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
WireGuardKitGo: update to latest wireguard-go tag
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 15 Dec 2020 12:16:35 +0000 (13:16 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 15 Dec 2020 12:16:52 +0000 (13:16 +0100)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Sources/WireGuardKit/WireGuardAdapter.swift
Sources/WireGuardKitGo/api-ios.go
Sources/WireGuardKitGo/go.mod
Sources/WireGuardKitGo/go.sum
Sources/WireGuardKitGo/wireguard.h

index f2e4040aa3f605f3b6b88306616a8d006f5d7035..6c2e956670471c8ac855dc69bd7f35967ff8f187 100644 (file)
@@ -152,10 +152,6 @@ public class WireGuardAdapter {
                 return
             }
 
-            #if os(macOS)
-            wgEnableRoaming(true)
-            #endif
-
             let networkMonitor = NWPathMonitor()
             networkMonitor.pathUpdateHandler = { [weak self] path in
                 self?.didReceivePathUpdate(path: path)
@@ -238,6 +234,9 @@ public class WireGuardAdapter {
                     self.logEndpointResolutionResults(resolutionResults)
 
                     wgSetConfig(handle, wgConfig)
+                    #if os(iOS)
+                    wgDisableSomeRoamingForBrokenMobileSemantics(handle)
+                    #endif
 
                     self.state = .started(handle, settingsGenerator)
 
@@ -346,11 +345,13 @@ public class WireGuardAdapter {
         }
 
         let handle = wgTurnOn(wgConfig, tunnelFileDescriptor)
-        if handle >= 0 {
-            return handle
-        } else {
+        if handle < 0 {
             throw WireGuardAdapterError.startWireGuardBackend(handle)
         }
+        #if os(iOS)
+        wgDisableSomeRoamingForBrokenMobileSemantics(handle)
+        #endif
+        return handle
     }
 
     /// Resolves the hostnames in the given tunnel configuration and return settings generator.
@@ -398,6 +399,7 @@ public class WireGuardAdapter {
                 self.logEndpointResolutionResults(resolutionResults)
 
                 wgSetConfig(handle, wgConfig)
+                wgDisableSomeRoamingForBrokenMobileSemantics(handle)
                 wgBumpSockets(handle)
             } else {
                 self.logHandler(.info, "Connectivity offline, pausing backend.")
index 0f803849b9256038ff584b765c778f2112df08b2..eaadea146022d32f1cb954a6e19449fd065e5eb6 100644 (file)
@@ -56,7 +56,6 @@ var tunnelHandles = make(map[int32]tunnelHandle)
 
 func init() {
        versionString = C.CString(device.WireGuardGoVersion)
-       device.RoamingDisabled = true
        signals := make(chan os.Signal)
        signal.Notify(signals, unix.SIGUSR2)
        go func() {
@@ -74,11 +73,6 @@ func init() {
        }()
 }
 
-//export wgEnableRoaming
-func wgEnableRoaming(enabled bool) {
-       device.RoamingDisabled = !enabled
-}
-
 //export wgSetLogger
 func wgSetLogger(context, loggerFn uintptr) {
        loggerCtx = unsafe.Pointer(context)
@@ -149,14 +143,17 @@ func wgTurnOff(tunnelHandle int32) {
 
 //export wgSetConfig
 func wgSetConfig(tunnelHandle int32, settings *C.char) int64 {
-       device, ok := tunnelHandles[tunnelHandle]
+       dev, ok := tunnelHandles[tunnelHandle]
        if !ok {
                return 0
        }
-       err := device.IpcSetOperation(bufio.NewReader(strings.NewReader(C.GoString(settings))))
+       err := dev.IpcSetOperation(bufio.NewReader(strings.NewReader(C.GoString(settings))))
        if err != nil {
-               device.Error.Println(err)
-               return err.ErrorCode()
+               dev.Error.Println(err)
+               if ipcErr, ok := err.(*device.IPCError); ok {
+                       return ipcErr.ErrorCode()
+               }
+               return -1
        }
        return 0
 }
@@ -187,6 +184,15 @@ func wgBumpSockets(tunnelHandle int32) {
        device.SendKeepalivesToPeersWithCurrentKeypair()
 }
 
+//export wgDisableSomeRoamingForBrokenMobileSemantics
+func wgDisableSomeRoamingForBrokenMobileSemantics(tunnelHandle int32) {
+       device, ok := tunnelHandles[tunnelHandle]
+       if !ok {
+               return
+       }
+       device.DisableSomeRoamingForBrokenMobileSemantics()
+}
+
 //export wgVersion
 func wgVersion() *C.char {
        return versionString
index eddf20c4e666b5a4cbecb81f47d062bfc6938c11..7eaab211079135cf9fdf5056d6cbe1353c5d1c06 100644 (file)
@@ -3,8 +3,8 @@ module golang.zx2c4.com/wireguard/ios
 go 1.13
 
 require (
-       golang.org/x/crypto v0.0.0-20200117160349-530e935923ad // indirect
-       golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa // indirect
-       golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9
-       golang.zx2c4.com/wireguard v0.0.20200121
+       golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 // indirect
+       golang.org/x/net v0.0.0-20201209123823-ac852fbbde11 // indirect
+       golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e
+       golang.zx2c4.com/wireguard v0.0.20201118
 )
index 74b3b2837cce3a47f2d4d2754aa1781227a4d75f..3f4e59c518733dee169508634aa534a84e0c55a5 100644 (file)
@@ -1,22 +1,24 @@
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc h1:c0o/qxkaO2LF5t6fQrT4b5hzyggAkLLlCUjqfRxd8Q4=
-golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/crypto v0.0.0-20200117160349-530e935923ad h1:Jh8cai0fqIK+f6nG0UgPW5wFk8wmiMhM3AyciDBdtQg=
-golang.org/x/crypto v0.0.0-20200117160349-530e935923ad/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
+golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 h1:sYNJzB4J8toYPQTM6pAkcmBRgw9SnQKP9oXCHfgy604=
+golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20191003171128-d98b1b443823 h1:Ypyv6BNJh07T1pUSrehkLemqPKXhus2MkfktJ91kRh4=
-golang.org/x/net v0.0.0-20191003171128-d98b1b443823/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa h1:F+8P+gmewFQYRk6JoLQLwjBCTu3mcIURZfNkVweuRKA=
-golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20201209123823-ac852fbbde11 h1:lwlPPsmjDKK0J6eG6xDWd5XPehI0R024zxjDnw3esPA=
+golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20191003212358-c178f38b412c h1:6Zx7DRlKXf79yfxuQ/7GqV3w2y7aDsk6bGg0MzF5RVU=
-golang.org/x/sys v0.0.0-20191003212358-c178f38b412c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 h1:1/DFK4b7JH8DmkqhUk48onnSfrPzImPoVxuomtbT2nk=
-golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201117222635-ba5294a509c7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e h1:AyodaIpKjppX+cBfTASF2E1US3H2JFBj920Ot3rtDjs=
+golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
-golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-golang.zx2c4.com/wireguard v0.0.20200121 h1:vcswa5Q6f+sylDfjqyrVNNrjsFUUbPsgAQTBCAg/Qf8=
-golang.zx2c4.com/wireguard v0.0.20200121/go.mod h1:P2HsVp8SKwZEufsnezXZA4GRX/T49/HlU7DGuelXsU4=
+golang.zx2c4.com/wireguard v0.0.20201118 h1:QL8y2C7uO8T6z1GY+UX/hSeWiYEBurQkXjOTRFtCvXU=
+golang.zx2c4.com/wireguard v0.0.20201118/go.mod h1:Dz+cq5bnrai9EpgYj4GDof/+qaGzbRWbeaAOs1bUYa0=
index 9da8cef25ce964c6230a9ec2f8391e96ccde7437..b49464e602b77430059f1624e30334900909f5c9 100644 (file)
 #include <stdbool.h>
 
 typedef void(*logger_fn_t)(void *context, int level, const char *msg);
-extern void wgEnableRoaming(bool enabled);
 extern void wgSetLogger(void *context, logger_fn_t logger_fn);
 extern int wgTurnOn(const char *settings, int32_t tun_fd);
 extern void wgTurnOff(int handle);
 extern int64_t wgSetConfig(int handle, const char *settings);
 extern char *wgGetConfig(int handle);
 extern void wgBumpSockets(int handle);
+extern void wgDisableSomeRoamingForBrokenMobileSemantics(int handle);
 extern const char *wgVersion();
 
 #endif