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

Method Ping

wgengine/userspace.go:1342–1369  ·  view source on GitHub ↗
(ip netip.Addr, pingType tailcfg.PingType, size int, cb func(*ipnstate.PingResult))

Source from the content-addressed store, hash-verified

1340}
1341
1342func (e *userspaceEngine) Ping(ip netip.Addr, pingType tailcfg.PingType, size int, cb func(*ipnstate.PingResult)) {
1343 res := &ipnstate.PingResult{IP: ip.String()}
1344 pip, ok := e.PeerForIP(ip)
1345 if !ok {
1346 e.logf("ping(%v): no matching peer", ip)
1347 res.Err = "no matching peer"
1348 cb(res)
1349 return
1350 }
1351 if pip.IsSelf {
1352 res.Err = fmt.Sprintf("%v is local Tailscale IP", ip)
1353 res.IsLocalIP = true
1354 cb(res)
1355 return
1356 }
1357 peer := pip.Node
1358
1359 e.logf("ping(%v): sending %v ping to %v %v ...", ip, pingType, peer.Key().ShortString(), peer.ComputedName())
1360 switch pingType {
1361 case "disco":
1362 e.magicConn.Ping(peer, res, size, cb)
1363 case "TSMP":
1364 e.sendTSMPPing(ip, peer, res, cb)
1365 e.sendTSMPDiscoAdvertisement(ip)
1366 case "ICMP":
1367 e.sendICMPEchoRequest(ip, peer, res, cb)
1368 }
1369}
1370
1371func (e *userspaceEngine) mySelfIPMatchingFamily(dst netip.Addr) (src netip.Addr, err error) {
1372 var zero netip.Addr

Callers

nothing calls this directly

Calls 10

PeerForIPMethod · 0.95
sendTSMPPingMethod · 0.95
sendICMPEchoRequestMethod · 0.95
ComputedNameMethod · 0.80
StringMethod · 0.65
KeyMethod · 0.65
PingMethod · 0.65
logfMethod · 0.45
ShortStringMethod · 0.45

Tested by

no test coverage detected