]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: add SendKeepalivesToPeersWithCurrentKeypair for handover
authorJason A. Donenfeld <Jason@zx2c4.com>
Thu, 30 May 2019 13:15:54 +0000 (15:15 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Thu, 30 May 2019 13:16:16 +0000 (15:16 +0200)
device/device.go

index fa7ed88fa720070fda57b66223dfb48f2728e488..77758447c366c756d1a2d8298e083c4e2cf74fb2 100644 (file)
@@ -396,3 +396,20 @@ func (device *Device) Close() {
 func (device *Device) Wait() chan struct{} {
        return device.signals.stop
 }
+
+func (device *Device) SendKeepalivesToPeersWithCurrentKeypair() {
+       if device.isClosed.Get() {
+               return
+       }
+
+       device.peers.RLock()
+       for _, peer := range device.peers.keyMap {
+               peer.keypairs.RLock()
+               sendKeepalive := peer.keypairs.current != nil && !peer.keypairs.current.created.Add(RejectAfterTime).Before(time.Now())
+               peer.keypairs.RUnlock()
+               if sendKeepalive {
+                       peer.SendKeepalive()
+               }
+       }
+       device.peers.RUnlock()
+}