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

Method updateMappingLocked

tailnet/peer.go:31–51  ·  view source on GitHub ↗

updateMappingLocked updates the mapping for another peer linked to this one by a tunnel. This method is NOT threadsafe and must be called while holding the core lock.

(id uuid.UUID, n *proto.Node, k proto.CoordinateResponse_PeerUpdate_Kind, reason string)

Source from the content-addressed store, hash-verified

29// updateMappingLocked updates the mapping for another peer linked to this one by a tunnel. This method
30// is NOT threadsafe and must be called while holding the core lock.
31func (p *peer) updateMappingLocked(id uuid.UUID, n *proto.Node, k proto.CoordinateResponse_PeerUpdate_Kind, reason string) error {
32 logger := p.logger.With(slog.F("from_id", id), slog.F("kind", k), slog.F("reason", reason))
33 update, err := p.storeMappingLocked(id, n, k, reason)
34 if xerrors.Is(err, errNoResp) {
35 logger.Debug(context.Background(), "skipping update")
36 return nil
37 }
38 if err != nil {
39 return err
40 }
41
42 req := &proto.CoordinateResponse{PeerUpdates: []*proto.CoordinateResponse_PeerUpdate{update}}
43 select {
44 case p.resps <- req:
45 p.lastWrite = time.Now()
46 logger.Debug(context.Background(), "wrote peer update")
47 return nil
48 default:
49 return ErrWouldBlock
50 }
51}
52
53// batchUpdateMapping updates the mappings for a list of peers linked to this one by a tunnel. This
54// method is NOT threadsafe and must be called while holding the core lock.

Callers 3

addTunnelLockedMethod · 0.80
removeTunnelLockedMethod · 0.80

Calls 2

storeMappingLockedMethod · 0.95
IsMethod · 0.45

Tested by

no test coverage detected