From: Jason A. Donenfeld Date: Thu, 30 May 2019 13:15:54 +0000 (+0200) Subject: device: add SendKeepalivesToPeersWithCurrentKeypair for handover X-Git-Tag: 0.0.20190805~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9f995209c3cc7bda242e8752680d78684fd62e4;p=thirdparty%2Fwireguard-go.git device: add SendKeepalivesToPeersWithCurrentKeypair for handover --- diff --git a/device/device.go b/device/device.go index fa7ed88..7775844 100644 --- a/device/device.go +++ b/device/device.go @@ -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() +}