dns

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

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

This section is empty.

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 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 ExtResolver

type ExtResolver struct {
	Cfg *dns.ClientConfig
	// 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() (*ExtResolver, error)

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