MCPcopy Create free account
hub / github.com/tailscale/tailcat / peerByIP

Method peerByIP

tailcat.go:1041–1054  ·  view source on GitHub ↗

peerByIP returns the public key of the peer that outbound packets addressed to dst should be sent to (see [wgengine.Engine.SetPeerByIPPacketFunc]).

(dst netip.Addr)

Source from the content-addressed store, hash-verified

1039// addressed to dst should be sent to (see
1040// [wgengine.Engine.SetPeerByIPPacketFunc]).
1041func (b *locoBackend) peerByIP(dst netip.Addr) (_ key.NodePublic, ok bool) {
1042 if !b.serverPub.IsZero() {
1043 // We're the client; all traffic goes to the server.
1044 return b.serverPub, true
1045 }
1046 b.mu.Lock()
1047 defer b.mu.Unlock()
1048 for k := range b.clients {
1049 if tcAddrForKey(k) == dst {
1050 return k, true
1051 }
1052 }
1053 return key.NodePublic{}, false
1054}
1055
1056// peerForIP is the [wgengine.Engine.SetPeerForIPFunc] callback,
1057// mapping a tailcat IPv6 address to its node in the network map. The

Callers 2

StartMethod · 0.80
initLockedMethod · 0.80

Calls 1

tcAddrForKeyFunction · 0.85

Tested by

no test coverage detected