MCPcopy Index your code
hub / github.com/coder/coder / peerLostTimeout

Method peerLostTimeout

tailnet/configmaps.go:566–606  ·  view source on GitHub ↗

peerLostTimeout is the callback that peerLifecycle uses when a peer is lost the timeout to receive a handshake fires.

(id uuid.UUID)

Source from the content-addressed store, hash-verified

564// peerLostTimeout is the callback that peerLifecycle uses when a peer is lost the timeout to
565// receive a handshake fires.
566func (c *configMaps) peerLostTimeout(id uuid.UUID) {
567 logger := c.logger.With(slog.F("peer_id", id))
568 logger.Debug(context.Background(),
569 "peer lost timeout")
570
571 // First do a status update to see if the peer did a handshake while we were
572 // waiting
573 status := c.status()
574 c.L.Lock()
575 defer c.L.Unlock()
576
577 lc, ok := c.peers[id]
578 if !ok {
579 logger.Debug(context.Background(),
580 "timeout triggered for peer that is removed from the map")
581 return
582 }
583 if lc.node != nil {
584 if peerStatus, ok := status.Peer[lc.node.Key]; ok {
585 lc.lastHandshake = peerStatus.LastHandshake
586 }
587 logger = logger.With(slog.F("key_id", lc.node.Key.ShortString()))
588 }
589 if !lc.lost {
590 logger.Debug(context.Background(),
591 "timeout triggered for peer that is no longer lost")
592 return
593 }
594 since := c.clock.Since(lc.lastHandshake)
595 if since >= lostTimeout {
596 logger.Info(
597 context.Background(), "removing lost peer")
598 delete(c.peers, id)
599 c.netmapDirty = true
600 c.Broadcast()
601 return
602 }
603 logger.Debug(context.Background(),
604 "timeout triggered for peer but it had handshake in meantime")
605 lc.setLostTimer(c)
606}
607
608func (c *configMaps) protoNodeToTailcfg(p *proto.Node) (*tailcfg.Node, error) {
609 node, err := ProtoToNode(p)

Callers 1

setLostTimerMethod · 0.80

Calls 5

statusMethod · 0.95
setLostTimerMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45
InfoMethod · 0.45

Tested by

no test coverage detected