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

Function handleClientNodeRequests

tailnet/tunnel.go:132–150  ·  view source on GitHub ↗

handleClientNodeRequests validates GetUpdateSelf requests and declines ReadyForHandshake requests

(req *proto.CoordinateRequest)

Source from the content-addressed store, hash-verified

130
131// handleClientNodeRequests validates GetUpdateSelf requests and declines ReadyForHandshake requests
132func handleClientNodeRequests(req *proto.CoordinateRequest) error {
133 if upd := req.GetUpdateSelf(); upd != nil {
134 for _, addrStr := range upd.Node.Addresses {
135 pre, err := netip.ParsePrefix(addrStr)
136 if err != nil {
137 return xerrors.Errorf("parse node address: %w", err)
138 }
139
140 if pre.Bits() != 128 {
141 return InvalidAddressBitsError{pre.Bits()}
142 }
143 }
144 }
145
146 if rfh := req.GetReadyForHandshake(); rfh != nil {
147 return xerrors.Errorf("clients may not send ready_for_handshake")
148 }
149 return nil
150}
151
152// tunnelStore contains tunnel information and allows querying it. It is not threadsafe and all
153// methods must be serialized by holding, e.g. the core mutex.

Callers 2

AuthorizeMethod · 0.85
AuthorizeMethod · 0.85

Calls 3

GetUpdateSelfMethod · 0.80
GetReadyForHandshakeMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected