dns

package
v0.11.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2020 License: Apache-2.0 Imports: 10 Imported by: 26

Documentation

Index

Constants

View Source
const (
	// A qtype performs A/AAAA lookup.
	A = QType("dns")
	// SRV qtype performs SRV lookup with A/AAAA lookup for each SRV result.
	SRV = QType("dnssrv")
	// SRVNoA qtype performs SRV lookup without any A/AAAA lookup for each SRV result.
	SRVNoA = QType("dnssrvnoa")
)

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 prometheus.Registerer, resolverType ResolverType) *Provider

NewProvider returns a new empty provider with a given resolver type. If empty resolver type is net.DefaultResolver.w

func (*Provider) Addresses

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

Addresses returns the latest addresses present in the Provider.

func (*Provider) Clone added in v0.10.0

func (p *Provider) Clone() *Provider

Clone returns a new provider from an existing one.

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 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 ipLookupResolver) Resolver

NewResolver creates a resolver with given underlying resolver.

type ResolverType added in v0.7.0

type ResolverType string
const (
	GolangResolverType   ResolverType = "golang"
	MiekgdnsResolverType ResolverType = "miekgdns"
)

func (ResolverType) ToResolver added in v0.7.0

func (t ResolverType) ToResolver(logger log.Logger) ipLookupResolver

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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