summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-30 15:15:54 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-30 15:16:16 +0200
commitd9f995209c3cc7bda242e8752680d78684fd62e4 (patch)
treeed04f6bf3dcde54aa36f14ba1197429653b1a1df
parentd0ab883adaae3b458ec6a54af04c9df347f378f5 (diff)
device: add SendKeepalivesToPeersWithCurrentKeypair for handover
-rw-r--r--device/device.go17
1 files changed, 17 insertions, 0 deletions
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()
+}