MCPcopy Create free account
hub / github.com/SamNet-dev/snix / resolveIPv4

Function resolveIPv4

cmd/snix/engine_linux.go:126–141  ·  view source on GitHub ↗
(host string)

Source from the content-addressed store, hash-verified

124}
125
126func resolveIPv4(host string) (netip.Addr, error) {
127 if a, err := netip.ParseAddr(host); err == nil && a.Is4() {
128 return a, nil
129 }
130 addrs, err := net.LookupIP(host)
131 if err != nil {
132 return netip.Addr{}, err
133 }
134 for _, a := range addrs {
135 if v4 := a.To4(); v4 != nil {
136 addr, _ := netip.AddrFromSlice(v4)
137 return addr, nil
138 }
139 }
140 return netip.Addr{}, fmt.Errorf("no IPv4 address for %s", host)
141}
142
143func defaultIfaceIPv4(remote netip.Addr) (netip.Addr, error) {
144 c, err := net.Dial("udp", net.JoinHostPort(remote.String(), "1"))

Callers 1

runEngineFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected