File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -387,9 +387,18 @@ func (c *configMaps) updatePeerLocked(update *proto.CoordinateResponse_PeerUpdat
387
387
return false
388
388
}
389
389
logger = logger .With (slog .F ("key_id" , node .Key .ShortString ()), slog .F ("node" , node ))
390
- // Since we don't send nodes into Tailscale unless we're sure that the
391
- // peer is ready for handshakes, we always enable keepalives.
392
- node .KeepAlive = true
390
+ peerStatus , ok := status .Peer [node .Key ]
391
+ // Starting KeepAlive messages at the initialization of a connection
392
+ // causes a race condition. If we send the handshake before the peer has
393
+ // our node, we'll have to wait for 5 seconds before trying again.
394
+ // Ideally, the first handshake starts when the user first initiates a
395
+ // connection to the peer. After a successful connection we enable
396
+ // keep alives to persist the connection and keep it from becoming idle.
397
+ // SSH connections don't send packets while idle, so we use keep alives
398
+ // to avoid random hangs while we set up the connection again after
399
+ // inactivity.
400
+ // TODO: tie this into waitForHandshake (upstack PR)
401
+ node .KeepAlive = ok && peerStatus .Active
393
402
}
394
403
switch {
395
404
case ! ok && update .Kind == proto .CoordinateResponse_PeerUpdate_NODE :
You can’t perform that action at this time.
0 commit comments