Help us shape the future of Go! Take the 2026 Go Developer Survey

resolver

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("no records found")

ErrNotFound is returned when no DNS records are found.

Functions

func GetDNSServers

func GetDNSServers() (nameservers []netip.AddrPort)

GetDNSServers returns the list of DNS servers from the local system configuration (e.g., /etc/resolv.conf).

func ValidateDNSServer

func ValidateDNSServer(servers []string) ([]string, error)

ValidateDNSServer validates a list of DNS servers by sending a query to each of them and checking if they respond with a valid answer. It returns a list of valid servers and an error if no valid server is found.

Types

type Options

type Options struct {
	// dns server for querying
	Servers   []string
	Hostsfile string
	Order     []string
	Timeout   time.Duration
	SkipTest  bool
}

Options contains configuration for the Resolver.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver is a DNS resolver that supports hosts file and caching.

func NewResolver

func NewResolver(option Options) (*Resolver, error)

NewResolver creates a new Resolver instance with the given options.

func (*Resolver) Close added in v0.9.0

func (r *Resolver) Close()

Close stops the DNS cache cleanup.

func (*Resolver) Lookup

func (r *Resolver) Lookup(ctx context.Context, host string, queryOrder ...[]string) ([]string, error)

Lookup returns a list of IP addresses for the given host.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL