MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / probeRoute

Function probeRoute

jsext/addrutil.go:56–71  ·  view source on GitHub ↗
(dst string)

Source from the content-addressed store, hash-verified

54var fallbackOwnAddress = netip.MustParseAddr("127.0.0.1")
55
56func probeRoute(dst string) (src netip.Addr) {
57 c, err := net.Dial("udp", net.JoinHostPort(dst, "53"))
58 if err != nil {
59 return
60 }
61 defer c.Close()
62 a := c.LocalAddr()
63 if a == nil {
64 return
65 }
66
67 if na, ok := a.(interface{ AddrPort() netip.AddrPort }); ok {
68 return na.AddrPort().Addr()
69 }
70 return
71}
72
73func myIPAddress() netip.Addr {
74 for _, a := range probingAddresses {

Callers 1

myIPAddressFunction · 0.85

Calls 4

AddrMethod · 0.80
DialMethod · 0.65
CloseMethod · 0.65
LocalAddrMethod · 0.45

Tested by

no test coverage detected