peerLostTimeout is the callback that peerLifecycle uses when a peer is lost the timeout to receive a handshake fires.
(id uuid.UUID)
| 564 | // peerLostTimeout is the callback that peerLifecycle uses when a peer is lost the timeout to |
| 565 | // receive a handshake fires. |
| 566 | func (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 | |
| 608 | func (c *configMaps) protoNodeToTailcfg(p *proto.Node) (*tailcfg.Node, error) { |
| 609 | node, err := ProtoToNode(p) |
no test coverage detected