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)
| 215 | // |
| 216 | // If nm is nil or no peer is found, ok is false. |
| 217 | func (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. |
no test coverage detected