Documentation
¶
Index ¶
- Variables
- func DNS(conf DNSResolverConfig) *dnsResolver
- func DNS64(resolver Resolver, conf *DNS64ResolverConfig) *dns64Resolver
- func Domain() (string, error)
- func Parallel(resolvers ...Resolver) *parallelResolver
- func Relative(resolver Resolver, conf *RelativeResolverConfig) *relativeResolver
- func Retry(resolver Resolver, conf *RetryResolverConfig) *retryResolver
- func RoundRobin(resolvers ...Resolver) *roundRobinResolver
- func Sequential(resolvers ...Resolver) *sequentialResolver
- type DNS64ResolverConfig
- type DNSResolverConfig
- type DNSTransport
- type DialContextFunc
- type HostsResolver
- type HostsResolverConfig
- type RelativeResolverConfig
- type Resolver
- type RetryResolverConfig
- type SystemResolverConfig
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func DNS64 ¶ added in v0.9.0
func DNS64(resolver Resolver, conf *DNS64ResolverConfig) *dns64Resolver
DNS64 returns a resolver that synthesizes IPv6 addresses from IPv4 addresses using DNS64 (RFC 6147).
func Parallel ¶ added in v0.6.0
func Parallel(resolvers ...Resolver) *parallelResolver
Parallel returns a resolver that tries each resolver in parallel until one succeeds.
func Relative ¶
func Relative(resolver Resolver, conf *RelativeResolverConfig) *relativeResolver
Relative returns a resolver that resolves relative hostnames.
func Retry ¶ added in v0.4.0
func Retry(resolver Resolver, conf *RetryResolverConfig) *retryResolver
Retry returns a resolver that retries a resolver a number of times.
func RoundRobin ¶ added in v0.4.0
func RoundRobin(resolvers ...Resolver) *roundRobinResolver
RoundRobin returns a Resolver that load balances between multiple resolvers using a round-robin strategy.
func Sequential ¶ added in v0.6.0
func Sequential(resolvers ...Resolver) *sequentialResolver
Sequential returns a resolver that tries each resolver in order until one succeeds.
Types ¶
type DNS64ResolverConfig ¶ added in v0.9.0
type DNS64ResolverConfig struct {
// Prefix is the IPv6 prefix to use.
// If not set, the well-known prefix "64:ff9b::/96" is used.
Prefix *netip.Prefix
// DialContext is used to establish a connection to a DNS server.
DialContext DialContextFunc
}
DNS64ResolverConfig is the configuration for a DNS64 resolver.
type DNSResolverConfig ¶
type DNSResolverConfig struct {
// Server is the DNS server to query.
Server netip.AddrPort
// Transport is the optional transport protocol used for DNS resolution.
// By default, plain DNS over UDP is used.
Transport *DNSTransport
// Timeout is the maximum duration to wait for a query to complete.
Timeout *time.Duration
// DialContext is used to establish a connection to a DNS server.
DialContext DialContextFunc
// TLSConfig is the configuration for the TLS client used for DNS over TLS.
TLSConfig *tls.Config
// SingleRequest is used to query A and AAAA records sequentially.
// This is mostly useful for avoiding conntrack race issues with DNS over UDP.
// If you feel the need to enable this, you should probably just use
// DNS over TCP instead.
SingleRequest *bool
}
DNSResolverConfig is the configuration for a DNS resolver.
type DNSTransport ¶ added in v0.6.0
type DNSTransport string
DNSTransport is the transport protocol used for DNS resolution.
const ( // DNSTransportUDP is DNS over UDP as defined in RFC 1035. DNSTransportUDP DNSTransport = "udp" // DNSTransportTCP is DNS over TCP as defined in RFC 1035. DNSTransportTCP DNSTransport = "tcp" // DNSTransportTLS is DNS over TLS as defined in RFC 7858. DNSTransportTLS DNSTransport = "tcp-tls" )
type DialContextFunc ¶ added in v0.6.0
DialContextFunc is a network dialer that can be used to dial a network.
type HostsResolver ¶ added in v0.11.1
type HostsResolver struct {
// contains filtered or unexported fields
}
func Hosts ¶ added in v0.6.0
func Hosts(conf *HostsResolverConfig) (*HostsResolver, error)
func (*HostsResolver) AddHost ¶ added in v0.11.1
func (r *HostsResolver) AddHost(host string, addrs ...netip.Addr)
AddHost adds an ephemeral host to the resolver with the given addresses.
func (*HostsResolver) LookupNetIP ¶ added in v0.11.1
func (*HostsResolver) RemoveHost ¶ added in v0.11.1
func (r *HostsResolver) RemoveHost(host string)
RemoveHost removes an ephemeral host from the resolver.
type HostsResolverConfig ¶ added in v0.6.0
type HostsResolverConfig struct {
// HostsFileReader is an optional reader that will be used as the source of the hosts file.
// If not provided, the OS's default hosts file will be used.
HostsFileReader io.Reader
// DialContext is an optional dialer used for ordering the returned addresses.
DialContext DialContextFunc
// NoHostsFile disables the use of the hosts file.
// This is useful when operating with only ephemeral hosts.
NoHostsFile *bool
}
type RelativeResolverConfig ¶
type RelativeResolverConfig struct {
// Search is a list of rooted suffixes to append to the relative name.
Search []string
// NDots is the number of dots in a name to trigger an absolute lookup.
NDots *int
}
RelativeResolverConfig is the configuration for a relative domain resolver.
type Resolver ¶
type Resolver interface {
// LookupNetIP looks up host using the resolver. It returns a slice of that
// host's IP addresses of the type specified by network. The network must be
// one of "ip", "ip4" or "ip6".
LookupNetIP(ctx context.Context, network, host string) ([]netip.Addr, error)
}
Resolver looks up names and numbers, this interface is also implemented by net.Resolver from the Go standard library.
func Literal ¶ added in v0.6.0
func Literal() Resolver
Literal returns a resolver that resolves IP literals.
func System ¶ added in v0.5.0
func System(conf *SystemResolverConfig) (Resolver, error)
System returns a Resolver that uses the system's default DNS configuration.
type RetryResolverConfig ¶ added in v0.4.0
type RetryResolverConfig struct {
// Attempts is the number of attempts to make before giving up.
// Setting this to 0 will cause the resolver to retry indefinitely.
Attempts *int
}
RetryResolverConfig is the configuration for a retry resolver.
type SystemResolverConfig ¶ added in v0.5.0
type SystemResolverConfig struct {
// HostsFilePath is the optional path to the hosts file.
// By default, the system's hosts file is used.
HostsFilePath string
// DialContext is used to establish a connection to a DNS server.
DialContext DialContextFunc
}
SystemResolverConfig is the configuration for a system resolver.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
module
|
|
|
internal
|
|
|
addrselect
Package addrselect implements RFC 6724, which describes the preferred source and destination address selection algorithm for Internet Protocol version 6 (IPv6) and Internet Protocol version 4 (IPv4).
|
Package addrselect implements RFC 6724, which describes the preferred source and destination address selection algorithm for Internet Protocol version 6 (IPv6) and Internet Protocol version 4 (IPv4). |