| 423 | } |
| 424 | |
| 425 | func (device *Device) SendKeepalivesToPeersWithCurrentKeypair() { |
| 426 | if !device.isUp() { |
| 427 | return |
| 428 | } |
| 429 | |
| 430 | device.peers.RLock() |
| 431 | for _, peer := range device.peers.keyMap { |
| 432 | peer.keypairs.RLock() |
| 433 | sendKeepalive := peer.keypairs.current != nil && !peer.keypairs.current.created.Add(RejectAfterTime).Before(time.Now()) |
| 434 | peer.keypairs.RUnlock() |
| 435 | if sendKeepalive { |
| 436 | peer.SendKeepalive() |
| 437 | } |
| 438 | } |
| 439 | device.peers.RUnlock() |
| 440 | } |
| 441 | |
| 442 | // closeBindLocked closes the device's net.bind. |
| 443 | // The caller must hold the net mutex. |