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

Function resolveIPv4

cmd/snix/engine_windows.go:125–140  ·  view source on GitHub ↗
(host string)

Source from the content-addressed store, hash-verified

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