Documentation ¶
Index ¶
- Constants
- Variables
- func AddrFromRR(rr dns.RR) netip.Addr
- func DnsTypeToString(qtype uint16) string
- func MinTTL(msg *dns.Msg) int
- type Cache
- func (cache *Cache) Clean()
- func (cache *Cache) Clear()
- func (cache *Cache) DnsGet(nsaddr netip.Addr, qname string, qtype uint16) (srv netip.Addr, msg *dns.Msg)
- func (cache *Cache) DnsResolve(ctx context.Context, qname string, qtype uint16) (msg *dns.Msg, srv netip.Addr, err error)
- func (cache *Cache) DnsSet(nsaddr netip.Addr, msg *dns.Msg)
- func (cache *Cache) Entries() (n int)
- func (cache *Cache) HitRatio() float64
- type Cacher
- type CachingResolver
- type Recursive
- func (r *Recursive) DnsResolve(ctx context.Context, qname string, qtype uint16) (msg *dns.Msg, srv netip.Addr, err error)
- func (r *Recursive) OrderRoots(ctx context.Context, dialer proxy.ContextDialer)
- func (r *Recursive) ResolveWithOptions(ctx context.Context, dialer proxy.ContextDialer, cache Cacher, logw io.Writer, ...) (*dns.Msg, netip.Addr, error)
- type Resolver
Constants ¶
View Source
const DefaultMaxTTL = 3600
View Source
const DefaultMinTTL = 10
View Source
const MaxQtype = 260
Variables ¶
View Source
var ( // ErrMaxDepth is returned when recursive resolving exceeds the allowed limit. ErrMaxDepth = fmt.Errorf("recursion depth exceeded %d", maxDepth) // ErrNoResponse is returned when no authoritative server could be successfully queried. // Consider it equivalent to SERVFAIL. ErrNoResponse = errors.New("no authoritative response") DefaultCache = NewCache() )
View Source
var Roots4 = []netip.Addr{ netip.AddrFrom4([4]byte([]byte{0xc0, 0x5, 0x5, 0xf1})), netip.AddrFrom4([4]byte([]byte{0xc0, 0x21, 0x4, 0xc})), netip.AddrFrom4([4]byte([]byte{0xc0, 0x24, 0x94, 0x11})), netip.AddrFrom4([4]byte([]byte{0xc0, 0x3a, 0x80, 0x1e})), netip.AddrFrom4([4]byte([]byte{0xc0, 0x70, 0x24, 0x4})), netip.AddrFrom4([4]byte([]byte{0xc0, 0xcb, 0xe6, 0xa})), netip.AddrFrom4([4]byte([]byte{0xc1, 0x0, 0xe, 0x81})), netip.AddrFrom4([4]byte([]byte{0xc6, 0x29, 0x0, 0x4})), netip.AddrFrom4([4]byte([]byte{0xc6, 0x61, 0xbe, 0x35})), netip.AddrFrom4([4]byte([]byte{0xc7, 0x7, 0x53, 0x2a})), netip.AddrFrom4([4]byte([]byte{0xc7, 0x7, 0x5b, 0xd})), netip.AddrFrom4([4]byte([]byte{0xc7, 0x9, 0xe, 0xc9})), netip.AddrFrom4([4]byte([]byte{0xca, 0xc, 0x1b, 0x21})), }
View Source
var Roots6 = []netip.Addr{ netip.AddrFrom16([16]byte([]byte{0x20, 0x1, 0x5, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x53})), netip.AddrFrom16([16]byte([]byte{0x20, 0x1, 0x5, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc})), netip.AddrFrom16([16]byte([]byte{0x20, 0x1, 0x5, 0x0, 0x0, 0x12, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xd, 0xd})), netip.AddrFrom16([16]byte([]byte{0x20, 0x1, 0x5, 0x0, 0x0, 0x2d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xd})), netip.AddrFrom16([16]byte([]byte{0x20, 0x1, 0x5, 0x0, 0x0, 0x2f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf})), netip.AddrFrom16([16]byte([]byte{0x20, 0x1, 0x5, 0x0, 0x0, 0x9f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x42})), netip.AddrFrom16([16]byte([]byte{0x20, 0x1, 0x5, 0x0, 0x0, 0xa8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe})), netip.AddrFrom16([16]byte([]byte{0x20, 0x1, 0x5, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb})), netip.AddrFrom16([16]byte([]byte{0x20, 0x1, 0x5, 0x3, 0xc, 0x27, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x30})), netip.AddrFrom16([16]byte([]byte{0x20, 0x1, 0x5, 0x3, 0xba, 0x3e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x30})), netip.AddrFrom16([16]byte([]byte{0x20, 0x1, 0x7, 0xfd, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1})), netip.AddrFrom16([16]byte([]byte{0x20, 0x1, 0x7, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x53})), netip.AddrFrom16([16]byte([]byte{0x20, 0x1, 0xd, 0xc3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x35})), }
Functions ¶
func DnsTypeToString ¶
Types ¶
type Cache ¶ added in v0.1.2
type Cache struct { MinTTL int // always cache responses for at least this long MaxTTL int // never cache responses for longer than this (excepting successful NS responses) // contains filtered or unexported fields }
func (*Cache) DnsResolve ¶ added in v0.2.0
type Cacher ¶ added in v0.1.4
type Cacher interface { // DnsSet may store a copy of msg with dns.Msg.Zero set to true and return it later with DnsGet. // If nsaddr is invalid, the entry may be returned for any later query matching just the // query name and type (a wildcard entry). DnsSet(nsaddr netip.Addr, msg *dns.Msg) // DnsGet returns the cached dns.Msg for the given qname and qtype that was returned from the // server at nsaddr. If that is not in the cache, a wildcard entry with an invalid address // may be returned if it exists. If no matching responses are available, nil is returned. // // dns.Msg.Zero must be set to true to indicate response is served from cache. DnsGet(nsaddr netip.Addr, qname string, qtype uint16) (netip.Addr, *dns.Msg) }
type CachingResolver ¶ added in v0.2.0
type Recursive ¶ added in v0.1.6
type Recursive struct {
// contains filtered or unexported fields
}
func NewWithOptions ¶
func (*Recursive) DnsResolve ¶ added in v0.2.0
func (r *Recursive) DnsResolve(ctx context.Context, qname string, qtype uint16) (msg *dns.Msg, srv netip.Addr, err error)
Resolve will perform a recursive DNS resolution for the provided name and record type.
func (*Recursive) OrderRoots ¶ added in v0.2.0
func (r *Recursive) OrderRoots(ctx context.Context, dialer proxy.ContextDialer)
OrderRoots sorts the root server list by their current latency and removes those that don't respond.
func (*Recursive) ResolveWithOptions ¶ added in v0.1.6
func (r *Recursive) ResolveWithOptions(ctx context.Context, dialer proxy.ContextDialer, cache Cacher, logw io.Writer, qname string, qtype uint16) (*dns.Msg, netip.Addr, error)
ResolveWithOptions will perform a recursive DNS resolution for the provided name and record type, using the given dialer, and if logw is non-nil, write a log of events.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.