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

Method peerForIP

tailcat.go:1059–1075  ·  view source on GitHub ↗

peerForIP is the [wgengine.Engine.SetPeerForIPFunc] callback, mapping a tailcat IPv6 address to its node in the network map. The engine uses it to find the peer for [wgengine.Engine.Ping].

(ip netip.Addr)

Source from the content-addressed store, hash-verified

1057// mapping a tailcat IPv6 address to its node in the network map. The
1058// engine uses it to find the peer for [wgengine.Engine.Ping].
1059func (b *locoBackend) peerForIP(ip netip.Addr) (_ wgengine.PeerForIP, ok bool) {
1060 var zero wgengine.PeerForIP
1061 b.mu.Lock()
1062 defer b.mu.Unlock()
1063 if b.nm == nil {
1064 return zero, false
1065 }
1066 if nodeHasAddr(b.nm.SelfNode, ip) {
1067 return wgengine.PeerForIP{Node: b.nm.SelfNode, IsSelf: true}, true
1068 }
1069 for _, p := range b.nm.Peers {
1070 if nodeHasAddr(p, ip) {
1071 return wgengine.PeerForIP{Node: p}, true
1072 }
1073 }
1074 return zero, false
1075}
1076
1077// onEngineStatus is the wgengine status callback. It watches for
1078// changes to our magicsock UDP endpoints (learned via STUN and from

Callers

nothing calls this directly

Calls 1

nodeHasAddrFunction · 0.85

Tested by

no test coverage detected