internal

package
v1.63.2 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package internal contains functionality internal to the dns resolver package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingAddr is the error returned when building a DNS resolver when
	// the provided target name is empty.
	ErrMissingAddr = errors.New("dns resolver: missing address")

	// ErrEndsWithColon is the error returned when building a DNS resolver when
	// the provided target name ends with a colon that is supposed to be the
	// separator between host and port.  E.g. "::" is a valid address as it is
	// an IPv6 address (host only) and "[::]:" is invalid as it ends with a
	// colon as the host and port separator
	ErrEndsWithColon = errors.New("dns resolver: missing port after port-separator colon")
)
View Source
var (
	// MinResolutionRate is the minimum rate at which re-resolutions are
	// allowed. This helps to prevent excessive re-resolution.
	MinResolutionRate = 30 * time.Second

	// TimeAfterFunc is used by the DNS resolver to wait for the given duration
	// to elapse. In non-test code, this is implemented by time.After.  In test
	// code, this can be used to control the amount of time the resolver is
	// blocked waiting for the duration to elapse.
	TimeAfterFunc func(time.Duration) <-chan time.Time

	// NewNetResolver returns the net.Resolver instance for the given target.
	NewNetResolver func(string) (NetResolver, error)

	// AddressDialer is the dialer used to dial the DNS server. It accepts the
	// Host portion of the URL corresponding to the user's dial target and
	// returns a dial function.
	AddressDialer func(address string) func(context.Context, string, string) (net.Conn, error)
)

The following vars are overridden from tests.

Functions

This section is empty.

Types

type NetResolver

type NetResolver interface {
	LookupHost(ctx context.Context, host string) (addrs []string, err error)
	LookupSRV(ctx context.Context, service, proto, name string) (cname string, addrs []*net.SRV, err error)
	LookupTXT(ctx context.Context, name string) (txts []string, err error)
}

NetResolver groups the methods on net.Resolver that are used by the DNS resolver implementation. This allows the default net.Resolver instance to be overidden from tests.

Jump to

Keyboard shortcuts

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