resolver

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Server *url.URL
}

Config controls hostname resolution. A nil Server uses the system resolver, a URL with an empty scheme uses UDP DNS, and http/https URLs use DoH.

type DNSRecord

type DNSRecord struct {
	IP  net.IP
	TTL int
}

DNSRecord is a resolved DNS answer with optional TTL metadata.

func LookupDOHType

func LookupDOHType(ctx context.Context, serverURL *url.URL, host, dnsType string, answerType int) ([]DNSRecord, error)

LookupDOHType resolves one DNS record family through a DNS-over-HTTPS JSON endpoint.

type Endpoint

type Endpoint struct {
	Host  string
	Port  string
	Addrs []net.IPAddr
}

Endpoint contains a parsed host:port address and its resolved IP addresses.

type Resolver

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

Resolver resolves names and dials addresses using the configured DNS backend.

func New

func New(cfg Config) *Resolver

New returns a resolver for the provided config.

func (*Resolver) DialContext

func (r *Resolver) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext resolves address and dials each returned IP until one succeeds.

func (*Resolver) LookupIPAddr

func (r *Resolver) LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error)

LookupIPAddr resolves host to IP addresses using the configured backend.

func (*Resolver) NetResolver

func (r *Resolver) NetResolver() *net.Resolver

NetResolver returns a net.Resolver for system or UDP DNS resolution. DoH resolution cannot be represented as a net.Resolver, so nil is returned.

func (*Resolver) ResolveAddress

func (r *Resolver) ResolveAddress(ctx context.Context, network, address string) (Endpoint, error)

ResolveAddress resolves the host portion of network address.

Jump to

Keyboard shortcuts

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