MCPcopy Create free account
hub / github.com/encodeous/nylon / ResolveName

Function ResolveName

state/dns.go:33–45  ·  view source on GitHub ↗

ResolveName resolves a hostname to a list of IP addresses

(ctx context.Context, host string)

Source from the content-addressed store, hash-verified

31
32// ResolveName resolves a hostname to a list of IP addresses
33func ResolveName(ctx context.Context, host string) ([]netip.Addr, error) {
34 ips, err := net.DefaultResolver.LookupHost(ctx, host)
35 if err != nil {
36 return nil, err
37 }
38 var addrs []netip.Addr
39 for _, ipStr := range ips {
40 if addr, err := netip.ParseAddr(ipStr); err == nil {
41 addrs = append(addrs, addr)
42 }
43 }
44 return addrs, nil
45}
46
47// ResolveSRV resolves an SRV record using the default resolver
48func ResolveSRV(ctx context.Context, service, proto, name string) (string, uint16, error) {

Callers 2

FetchConfigFunction · 0.92
RefreshMethod · 0.85

Calls 1

LookupHostMethod · 0.80

Tested by

no test coverage detected