dns

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: Apache-2.0 Imports: 14 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

func GetQTypeName added in v0.12.0

func GetQTypeName(addr string) (qtype, name string)

GetQTypeName splits the provided addr into two parts: the QType (if any) and the name.

func IsDynamicNode added in v0.12.0

func IsDynamicNode(addr string) bool

IsDynamicNode returns if the specified StoreAPI addr uses any kind of SD mechanism.

Types

type Provider

type Provider struct {
	sync.RWMutex
	// 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.

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) error

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). For non-SRV records, it will return an error if 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, logger log.Logger) 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