dns

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	A   = QType("dns")
	SRV = QType("dnssrv")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Provider is a stateful cache for asynchronous DNS resolutions. It provides a way to resolve addresses and obtain them.

func NewProvider

func NewProvider(logger log.Logger, reg *extprom.SubsystemRegisterer) *Provider

NewProvider returns a new empty provider with a default resolver.

func (*Provider) Addresses

func (p *Provider) Addresses() []string

Addresses returns the latest addresses present in the Provider.

func (*Provider) Resolve

func (p *Provider) Resolve(ctx context.Context, addrs []string)

Resolve stores a list of provided addresses or their DNS records if requested. Addresses prefixed with `dns+` or `dnssrv+` will be resolved through respective DNS lookup (A/AAAA or SRV). defaultPort is used for non-SRV records when a port is not supplied.

type QType added in v0.2.1

type QType string

type Resolver

type Resolver interface {

	// Resolve performs a DNS lookup and returns a list of records.
	// name is the domain name to be resolved.
	// qtype is the query type. Accepted values are `dns` for A/AAAA lookup and `dnssrv` for SRV lookup.
	// If qtype is `dns`, the domain name to be resolved requires a port or an error will be returned.
	// If scheme is passed through name, it is preserved on IP results.
	Resolve(ctx context.Context, name string, qtype QType) ([]string, error)
}

func NewResolver

func NewResolver() Resolver

NewResolver provides a resolver with a specific net.Resolver. If resolver is nil, the default resolver will be used.

Jump to

Keyboard shortcuts

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