MCPcopy Create free account
hub / github.com/coder/coder / authorizeNodePrefixes

Method authorizeNodePrefixes

tailnet/tunnel.go:91–110  ·  view source on GitHub ↗

authorizeNodePrefixes verifies that every prefix is a /128 address derived from the agent's own UUID (or the legacy workspace agent IP).

(prefixes []string)

Source from the content-addressed store, hash-verified

89// authorizeNodePrefixes verifies that every prefix is a /128 address derived
90// from the agent's own UUID (or the legacy workspace agent IP).
91func (a AgentCoordinateeAuth) authorizeNodePrefixes(prefixes []string) error {
92 for _, prefixStr := range prefixes {
93 pre, err := netip.ParsePrefix(prefixStr)
94 if err != nil {
95 return xerrors.Errorf("parse node address: %w", err)
96 }
97
98 if pre.Bits() != 128 {
99 return InvalidAddressBitsError{pre.Bits()}
100 }
101
102 if TailscaleServicePrefix.AddrFromUUID(a.ID).Compare(pre.Addr()) != 0 &&
103 CoderServicePrefix.AddrFromUUID(a.ID).Compare(pre.Addr()) != 0 &&
104 legacyWorkspaceAgentIP.Compare(pre.Addr()) != 0 {
105 return InvalidNodeAddressError{pre.Addr().String()}
106 }
107 }
108
109 return nil
110}
111
112type ClientUserCoordinateeAuth struct {
113 Auth TunnelAuthorizer

Callers 1

AuthorizeMethod · 0.95

Calls 5

CompareMethod · 0.80
AddrFromUUIDMethod · 0.80
ErrorfMethod · 0.45
AddrMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected