dns

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: GPL-3.0 Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dns defines interfaces used by maddy modules to perform DNS lookups.

Currently, there is only Resolver interface which is implemented by dns.DefaultResolver(). In the future, DNSSEC-enabled stub resolver implementation will be added here.

Index

Constants

View Source
const DefaultConfigPath = "/etc/resolv.conf"

Variables

This section is empty.

Functions

func Equal

func Equal(domain1, domain2 string) bool

Equal reports whether domain1 and domain2 are equivalent as defined by IDNA2008 (RFC 5890).

TL;DR Use this instead of strings.EqualFold to compare domains.

Equivalence for malformed A-label domains is defined using regular byte-string comparison with case-folding applied.

func FQDN added in v0.4.3

func FQDN(domain string) string

func ForLookup

func ForLookup(domain string) (string, error)

ForLookup converts the domain into a canonical form suitable for table lookups and other comparisons.

TL;DR Use this instead of strings.ToLower to prepare domain for lookups.

Domains that contain invalid UTF-8 or invalid A-label domains are simply converted to local-case using strings.ToLower, but the error is also returned.

func ForLookupASCII added in v0.9.7

func ForLookupASCII(domain string) (string, error)

ForLookupASCII converts the domain into a canonical form suitable for table lookups and other comparisons.

As compared to ForLookup (returning U-labels), this function returns A-labels representation.

func IsNotFound

func IsNotFound(err error) bool

func LookupAddr

func LookupAddr(ctx context.Context, r Resolver, ip net.IP) (string, error)

LookupAddr is a convenience wrapper for Resolver.LookupAddr.

It returns the first name with trailing dot stripped.

func SelectIDNA

func SelectIDNA(ulabel bool, domain string) (string, error)

SelectIDNA is a convenience function for encoding to/from Punycode.

If ulabel is true, it returns U-label encoded domain in the Unicode NFC form. If ulabel is false, it returns A-label encoded domain.

Types

type ClientConfig added in v0.9.7

type ClientConfig = dns.ClientConfig

ClientConfig is the DNS client configuration accepted by NewFromConfig.

type ExtResolver

type ExtResolver struct {
	// contains filtered or unexported fields
}

ExtResolver is a convenience wrapper for miekg/dns library that provides access to certain low-level functionality (notably, AD flag in responses, indicating whether DNSSEC verification was performed by the server).

func NewExtResolver

func NewExtResolver(opts ...Option) (*ExtResolver, error)

NewExtResolver constructs a resolver using the system configuration.

func NewFromConfig added in v0.9.7

func NewFromConfig(cfg *ClientConfig, opts ...Option) (*ExtResolver, error)

NewFromConfig constructs a resolver with a fixed configuration. It ignores system override.

func NewFromConfigFile added in v0.9.7

func NewFromConfigFile(confPath string, opts ...Option) (*ExtResolver, error)

NewFromConfigFile constructs a resolver that checks the file for changes.

func (*ExtResolver) AuthLookupAddr

func (e *ExtResolver) AuthLookupAddr(ctx context.Context, addr string) (ad bool, names []string, err error)

func (*ExtResolver) AuthLookupCNAME added in v0.4.3

func (e *ExtResolver) AuthLookupCNAME(ctx context.Context, host string) (ad bool, cname string, err error)

func (*ExtResolver) AuthLookupHost

func (e *ExtResolver) AuthLookupHost(ctx context.Context, host string) (ad bool, addrs []string, err error)

func (*ExtResolver) AuthLookupIPAddr

func (e *ExtResolver) AuthLookupIPAddr(ctx context.Context, host string) (ad bool, addrs []net.IPAddr, err error)

func (*ExtResolver) AuthLookupMX

func (e *ExtResolver) AuthLookupMX(ctx context.Context, name string) (ad bool, mxs []*net.MX, err error)

func (*ExtResolver) AuthLookupTLSA

func (e *ExtResolver) AuthLookupTLSA(ctx context.Context, service, network, domain string) (ad bool, recs []TLSA, err error)

func (*ExtResolver) AuthLookupTXT

func (e *ExtResolver) AuthLookupTXT(ctx context.Context, name string) (ad bool, recs []string, err error)

func (*ExtResolver) CheckCNAMEAD added in v0.4.3

func (e *ExtResolver) CheckCNAMEAD(ctx context.Context, host string) (ad bool, rname string, err error)

CheckCNAMEAD is a special function for use in DANE lookups. It attempts to determine final (canonical) name of the host and also reports whether the whole chain of CNAME's and final zone are "secure".

If there are no A or AAAA records for host, rname = "" is returned.

type Option added in v0.9.7

type Option = func(*ExtResolver)

Option customizes an ExtResolver during construction.

func WithLogger added in v0.9.7

func WithLogger(logger *log.Logger) Option

WithLogger sets the logger used by the resolver.

type RCodeError

type RCodeError struct {
	Name string
	Code int
}

RCodeError is returned by ExtResolver when the RCODE in response is not NOERROR.

func (RCodeError) Error

func (err RCodeError) Error() string

func (RCodeError) Temporary

func (err RCodeError) Temporary() bool

type Resolver

type Resolver interface {
	LookupAddr(ctx context.Context, addr string) (names []string, err error)
	LookupHost(ctx context.Context, host string) (addrs []string, err error)
	LookupMX(ctx context.Context, name string) ([]*net.MX, error)
	LookupTXT(ctx context.Context, name string) ([]string, error)
	LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error)
}

Resolver is an interface that describes DNS-related methods used by maddy.

It is implemented by dns.DefaultResolver(). Methods behave the same way.

func DefaultResolver

func DefaultResolver() Resolver

type TLSA

type TLSA = dns.TLSA

Jump to

Keyboard shortcuts

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