(src *peer, dstID uuid.UUID)
| 399 | } |
| 400 | |
| 401 | func (c *core) removeTunnelLocked(src *peer, dstID uuid.UUID) error { |
| 402 | err := src.updateMappingLocked(dstID, nil, proto.CoordinateResponse_PeerUpdate_DISCONNECTED, "remove tunnel") |
| 403 | if err != nil { |
| 404 | src.logger.Error(context.Background(), "failed to update", slog.Error(err)) |
| 405 | c.removePeerLocked(src.id, proto.CoordinateResponse_PeerUpdate_DISCONNECTED, "failed update", "failed to remove tunnel dest mapping") |
| 406 | // removing the peer also removes all other tunnels and notifies destinations, so it's safe to |
| 407 | // return here. |
| 408 | return err |
| 409 | } |
| 410 | dst, ok := c.peers[dstID] |
| 411 | if ok { |
| 412 | err = dst.updateMappingLocked(src.id, nil, proto.CoordinateResponse_PeerUpdate_DISCONNECTED, "remove tunnel") |
| 413 | if err != nil { |
| 414 | dst.logger.Error(context.Background(), "failed to update", slog.Error(err)) |
| 415 | c.removePeerLocked(dst.id, proto.CoordinateResponse_PeerUpdate_DISCONNECTED, "failed update", "failed to remove tunnel src mapping") |
| 416 | // don't return here because we still want to remove the tunnel, and an error at the |
| 417 | // destination doesn't count as an error removing the tunnel at the source. |
| 418 | } |
| 419 | } |
| 420 | c.tunnels.remove(src.id, dstID) |
| 421 | return nil |
| 422 | } |
| 423 | |
| 424 | func (c *core) initPeer(p *peer) error { |
| 425 | c.mutex.Lock() |
no test coverage detected