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

Method removeTunnelLocked

tailnet/coordinator.go:401–422  ·  view source on GitHub ↗
(src *peer, dstID uuid.UUID)

Source from the content-addressed store, hash-verified

399}
400
401func (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
424func (c *core) initPeer(p *peer) error {
425 c.mutex.Lock()

Callers 1

handleRequestMethod · 0.95

Calls 4

removePeerLockedMethod · 0.95
updateMappingLockedMethod · 0.80
removeMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected