Documentation ¶
Index ¶
Constants ¶
const MinCacheCapacity = 1000
const NameCollision = "127.0.53.53"
ICANN specifies that DNS servers should return the special value 127.0.53.53 for A record queries of TLDs that have recently entered the root zone, that have a high likelyhood of colliding with private DNS names. The record returned is a notice to network administrators to adjust their DNS configuration. https://www.icann.org/resources/pages/name-collision-2013-12-06-en#127.0.53.53
Variables ¶
var ( Timeout = 2000 * time.Millisecond TypicalResponseTime = 100 * time.Millisecond MaxRecursion = 10 MaxNameservers = 2 MaxIPs = 2 )
DNS Resolution configuration.
var ( NXDOMAIN = fmt.Errorf("NXDOMAIN") ErrMaxRecursion = fmt.Errorf("maximum recursion depth reached: %d", MaxRecursion) ErrMaxIPs = fmt.Errorf("maximum name server IPs queried: %d", MaxIPs) ErrNoARecords = fmt.Errorf("no A records found for name server") ErrNoResponse = fmt.Errorf("no responses received") ErrTimeout = fmt.Errorf("timeout expired") // TODO: Timeouter interface? e.g. func (e) Timeout() bool { return true } )
Resolver errors.
var DebugLogger io.Writer
DebugLogger will receive writes of DNS resolution traces if not nil.
Functions ¶
This section is empty.
Types ¶
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver implements a primitive, non-recursive, caching DNS resolver.
func New ¶
New initializes a Resolver with the specified cache size. Deprecated: Use NewResolver instead.
func NewExpiring ¶
NewExpiring initializes an expiring Resolver with the specified cache size. Deprecated: Use NewResolver instead.
func NewExpiringWithTimeout ¶
NewExpiringWithTimeout initializes an expiring Resolved with the specified cache size and resolution timeout. Deprecated: Use NewResolver instead.
func NewResolver ¶
func NewResolver(options ...ResolverOption) (*Resolver, error)
NewResolver creates a resolver with the given cache capacity and a set of extra options.
func NewWithTimeout ¶
NewWithTimeout initializes a Resolver with the specified cache size and resolution timeout. Deprecated: Use NewResolver instead.
func (*Resolver) Resolve ¶
Resolve calls ResolveErr to find DNS records of type qtype for the domain qname. For nonexistent domains (NXDOMAIN), it will return an empty, non-nil slice.
func (*Resolver) ResolveCtx ¶
ResolveCtx finds DNS records of type qtype for the domain qname using the supplied context. Requests may time out earlier if timeout is shorter than a deadline set in ctx. For nonexistent domains, it will return an NXDOMAIN error. Specify an empty string in qtype to receive any DNS records found (currently A, AAAA, NS, CNAME, SOA, and TXT).
func (*Resolver) ResolveErr ¶
ResolveErr finds DNS records of type qtype for the domain qname. For nonexistent domains, it will return an NXDOMAIN error. Specify an empty string in qtype to receive any DNS records found (currently A, AAAA, NS, CNAME, SOA, and TXT).
type ResolverOption ¶
type ResolverOption resolverOption
ResolverOption configures a single resolver setting
func Expiring ¶ added in v0.0.4
func Expiring() ResolverOption
Expiring returns a resolverOption that can be used on NewResolver to change the resolver cache to be expiring.
func WithCapacity ¶ added in v0.0.4
func WithCapacity(capacity int) ResolverOption
WithCapacity returns a resolverOption that can be used on NewResolver to change the cache capacity of the resolver.
func WithDialer ¶
func WithDialer(dialer *net.Dialer) ResolverOption
WithDialer returns a resolverOption that can be used on NewResolver to change the resolver dialer. A custom dialer can be used to specify the local ip address.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ResolverOption
WithTimeout returns a resolverOption that can be used on NewResolver to change the timeout of the name resolution.