]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: remove global for roaming escape hatch
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 7 Oct 2020 08:17:48 +0000 (10:17 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 14 Oct 2020 08:45:31 +0000 (10:45 +0200)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
device/mobilequirks.go [new file with mode: 0644]
device/peer.go

diff --git a/device/mobilequirks.go b/device/mobilequirks.go
new file mode 100644 (file)
index 0000000..fc0b386
--- /dev/null
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2020 WireGuard LLC. All Rights Reserved.
+ */
+
+package device
+
+func (device *Device) DisableSomeRoamingForBrokenMobileSemantics() {
+       device.peers.RLock()
+       for _, peer := range device.peers.keyMap {
+               peer.Lock()
+               defer peer.Unlock()
+               peer.disableRoaming = peer.endpoint != nil
+       }
+       device.peers.RUnlock()
+}
\ No newline at end of file
index d13acd9938423e096ab167c0ea5e7e40bbebe0bf..8cb0dc26f7f4c0321d899d9f6dce5bf3540fceb8 100644 (file)
@@ -28,6 +28,7 @@ type Peer struct {
        device                      *Device
        endpoint                    conn.Endpoint
        persistentKeepaliveInterval uint16
+       disableRoaming              bool
 
        // These fields are accessed with atomic operations, which must be
        // 64-bit aligned even on 32-bit platforms. Go guarantees that an
@@ -290,10 +291,9 @@ func (peer *Peer) Stop() {
        peer.ZeroAndFlushAll()
 }
 
-var RoamingDisabled bool
 
 func (peer *Peer) SetEndpointFromPacket(endpoint conn.Endpoint) {
-       if RoamingDisabled {
+       if peer.disableRoaming {
                return
        }
        peer.Lock()