Skip to content

Commit 7e2d1bb

Browse files
committed
fixup! spike comments
1 parent 4b14af0 commit 7e2d1bb

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tailnet/configmaps.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,18 @@ func (c *configMaps) updatePeerLocked(update *proto.CoordinateResponse_PeerUpdat
387387
return false
388388
}
389389
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
393402
}
394403
switch {
395404
case !ok && update.Kind == proto.CoordinateResponse_PeerUpdate_NODE:

0 commit comments

Comments
 (0)