dns

package
v0.0.0-...-22cde92 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 16

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

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

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

func IsDynamicNode

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

func (p *Provider) Clone() *Provider

Clone returns a new provider from an existing one.

func (*Provider) Collect

func (p *Provider) Collect(ch chan<- prometheus.Metric)

Describe implements prometheus.Collector

func (*Provider) Describe

func (p *Provider) Describe(ch chan<- *prometheus.Desc)

Describe implements prometheus.Collector

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

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

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

func (ResolverType) ToResolver

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