removePeer removes and cleans up a lost peer. It updates all peers it shares a tunnel with, deletes all tunnels from which the removed peer is the source.
(p *peer, closeErr string)
| 460 | // removePeer removes and cleans up a lost peer. It updates all peers it shares a tunnel with, deletes |
| 461 | // all tunnels from which the removed peer is the source. |
| 462 | func (c *core) lostPeer(p *peer, closeErr string) error { |
| 463 | c.mutex.Lock() |
| 464 | defer c.mutex.Unlock() |
| 465 | c.logger.Debug(context.Background(), "lostPeer", slog.F("peer_id", p.id)) |
| 466 | if c.closed { |
| 467 | return ErrClosed |
| 468 | } |
| 469 | if existing, ok := c.peers[p.id]; !ok || existing != p { |
| 470 | return ErrAlreadyRemoved |
| 471 | } |
| 472 | c.removePeerLocked(p.id, proto.CoordinateResponse_PeerUpdate_LOST, "lost", closeErr) |
| 473 | return nil |
| 474 | } |
| 475 | |
| 476 | func (c *core) removePeerLocked(id uuid.UUID, kind proto.CoordinateResponse_PeerUpdate_Kind, reason, closeErr string) { |
| 477 | p, ok := c.peers[id] |
no test coverage detected