Skip to content

Commit cdecac1

Browse files
committed
Add inactivity ping
1 parent 8afca6c commit cdecac1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tailnet/conn.go

+10
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,17 @@ func (c *Conn) UpdateNodes(nodes []*Node) error {
302302
for _, peer := range c.netMap.Peers {
303303
if peerStatus, ok := status.Peer[peer.Key]; ok {
304304
// Clear out inactive connections!
305+
// If the connection hasn't been written to in a while, we manually
306+
// send a ping to ensure it's still alive.
305307
if !peerStatus.Active {
308+
c.Ping(peer.Addresses[0].Addr(), tailcfg.PingDisco, func(pr *ipnstate.PingResult) {
309+
if pr.Err != "" {
310+
// If an error happened during ping (like no route to host),
311+
// we omit it from being added to the map, and go on!
312+
return
313+
}
314+
peerMap[peer.ID] = peer
315+
})
306316
continue
307317
}
308318
}

0 commit comments

Comments
 (0)