MCPcopy Index your code
hub / github.com/tailscale/tailscale / PeerByTailscaleIP

Method PeerByTailscaleIP

types/netmap/netmap.go:217–232  ·  view source on GitHub ↗

PeerByTailscaleIP returns a peer's Node based on its Tailscale IP. If nm is nil or no peer is found, ok is false.

(ip netip.Addr)

Source from the content-addressed store, hash-verified

215//
216// If nm is nil or no peer is found, ok is false.
217func (nm *NetworkMap) PeerByTailscaleIP(ip netip.Addr) (peer tailcfg.NodeView, ok bool) {
218 // TODO(bradfitz):
219 if nm == nil {
220 return tailcfg.NodeView{}, false
221 }
222 for _, n := range nm.Peers {
223 ad := n.Addresses()
224 for i := range ad.Len() {
225 a := ad.At(i)
226 if a.Addr() == ip {
227 return n, true
228 }
229 }
230 }
231 return tailcfg.NodeView{}, false
232}
233
234// PeerIndexByNodeID returns the index of the peer with the given nodeID
235// in nm.Peers, or -1 if nm is nil or not found.

Callers 1

pingPeerAPIMethod · 0.80

Calls 4

AddressesMethod · 0.80
LenMethod · 0.65
AtMethod · 0.45
AddrMethod · 0.45

Tested by

no test coverage detected