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

Method mySelfIPMatchingFamily

wgengine/userspace.go:1371–1388  ·  view source on GitHub ↗
(dst netip.Addr)

Source from the content-addressed store, hash-verified

1369}
1370
1371func (e *userspaceEngine) mySelfIPMatchingFamily(dst netip.Addr) (src netip.Addr, err error) {
1372 var zero netip.Addr
1373 e.mu.Lock()
1374 defer e.mu.Unlock()
1375 if e.netMap == nil {
1376 return zero, errors.New("no netmap")
1377 }
1378 addrs := e.netMap.GetAddresses()
1379 if addrs.Len() == 0 {
1380 return zero, errors.New("no self address in netmap")
1381 }
1382 for _, p := range addrs.All() {
1383 if p.IsSingleIP() && p.Addr().BitLen() == dst.BitLen() {
1384 return p.Addr(), nil
1385 }
1386 }
1387 return zero, errors.New("no self address in netmap matching address family")
1388}
1389
1390func (e *userspaceEngine) sendICMPEchoRequest(destIP netip.Addr, peer tailcfg.NodeView, res *ipnstate.PingResult, cb func(*ipnstate.PingResult)) {
1391 srcIP, err := e.mySelfIPMatchingFamily(destIP)

Callers 3

sendICMPEchoRequestMethod · 0.95
sendTSMPPingMethod · 0.95

Calls 7

GetAddressesMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
LenMethod · 0.65
AllMethod · 0.65
NewMethod · 0.45
AddrMethod · 0.45

Tested by

no test coverage detected