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

Method isSelfDst

wgengine/netstack/netstack.go:1171–1180  ·  view source on GitHub ↗

isSelfDst reports whether pkt's destination IP is a local Tailscale IP assigned to this node. This is used by inject() to detect self-addressed packets that need loopback delivery.

(pkt *stack.PacketBuffer)

Source from the content-addressed store, hash-verified

1169// assigned to this node. This is used by inject() to detect self-addressed
1170// packets that need loopback delivery.
1171func (ns *Impl) isSelfDst(pkt *stack.PacketBuffer) bool {
1172 hdr := pkt.Network()
1173 switch v := hdr.(type) {
1174 case header.IPv4:
1175 return ns.isLocalIP(netip.AddrFrom4(v.DestinationAddress().As4()))
1176 case header.IPv6:
1177 return ns.isLocalIP(netip.AddrFrom16(v.DestinationAddress().As16()))
1178 }
1179 return false
1180}
1181
1182// isLocalIP reports whether ip is a Tailscale IP assigned to this
1183// node directly (but not a subnet-routed IP).

Callers 2

injectMethod · 0.95
TestIsSelfDstFunction · 0.80

Calls 2

isLocalIPMethod · 0.95
NetworkMethod · 0.45

Tested by 1

TestIsSelfDstFunction · 0.64