Documentation ¶
Index ¶
- Constants
- Variables
- func ClientSubnetCheck(resolver string) error
- func FirstProperSubdomain(ctx context.Context, r Resolver, name string, priority int) string
- func NsecTraversal(ctx context.Context, r Resolver, domain string, priority int) ([]*dns.NSEC, bool, error)
- func PoolRetryPolicy(times, priority int, msg *dns.Msg) bool
- func QueryMsg(name string, qtype uint16) *dns.Msg
- func RemoveLastDot(name string) string
- func RetryPolicy(times, priority int, msg *dns.Msg) bool
- func ReverseMsg(addr string) *dns.Msg
- func SetupOptions() *dns.OPT
- func UnlikelyName(sub string) string
- func WalkMsg(name string, qtype uint16) *dns.Msg
- type ExtractedAnswer
- type ResolveError
- type Resolver
- type Retry
Constants ¶
const ( PriorityLow int = iota PriorityNormal PriorityHigh PriorityCritical )
The priority levels for Resolver DNS queries.
const ( AttemptsPriorityLow int = 50 AttemptsPriorityNormal int = 100 AttemptsPriorityHigh int = 250 AttemptsPriorityCritical int = 500 )
The priority levels for Resolver DNS queries.
const ( MaxDNSNameLen = 253 MaxDNSLabelLen = 63 MinLabelLen = 6 MaxLabelLen = 24 LDHChars = "abcdefghijklmnopqrstuvwxyz0123456789-" )
Constants related to DNS labels.
const ( WildcardTypeNone = iota WildcardTypeStatic WildcardTypeDynamic )
Names for the different types of wildcards that can be detected.
const ResolverErrRcode = 100
ResolverErrRcode is our made up rcode to indicate an interface error.
const TimeoutRcode = 101
TimeoutRcode is our made up rcode to indicate that a query timed out.
Variables ¶
var PoolRetryCodes = []int{ TimeoutRcode, ResolverErrRcode, dns.RcodeRefused, dns.RcodeServerFailure, dns.RcodeNotImplemented, }
PoolRetryCodes are the rcodes that cause the pool to suggest trying again.
var QueryTimeout = 2 * time.Second
QueryTimeout is the duration until a Resolver query expires.
var RetryCodes = []int{ TimeoutRcode, ResolverErrRcode, }
RetryCodes are the rcodes that cause the resolver to suggest trying again.
Functions ¶
func ClientSubnetCheck ¶
ClientSubnetCheck ensures that the provided resolver does not send the EDNS client subnet information. The function returns the DNS reply size limit in number of bytes.
func FirstProperSubdomain ¶
FirstProperSubdomain returns the first subdomain name using the provided name and Resolver that responds successfully to a DNS query for the NS record type.
func NsecTraversal ¶
func NsecTraversal(ctx context.Context, r Resolver, domain string, priority int) ([]*dns.NSEC, bool, error)
NsecTraversal attempts to retrieve a DNS zone using NSEC-walking.
func PoolRetryPolicy ¶
PoolRetryPolicy is the default policy used by the resolver pool to determine if a DNS query should be performed again.
func RemoveLastDot ¶
RemoveLastDot removes the '.' at the end of the provided FQDN.
func RetryPolicy ¶
RetryPolicy is the default policy used to determine if a DNS query should be performed again.
func ReverseMsg ¶
ReverseMsg generates a message used for a reverse DNS query.
func SetupOptions ¶
SetupOptions returns the EDNS0_SUBNET option for hiding our location.
func UnlikelyName ¶
UnlikelyName takes a subdomain name and returns an unlikely DNS name within that subdomain.
Types ¶
type ExtractedAnswer ¶
ExtractedAnswer contains information from the DNS response Answer section.
func AnswersByType ¶
func AnswersByType(answers []*ExtractedAnswer, qtype uint16) []*ExtractedAnswer
AnswersByType returns only the answers from the DNS Answer section matching the provided type.
func ExtractAnswers ¶
func ExtractAnswers(msg *dns.Msg) []*ExtractedAnswer
ExtractAnswers returns information from the DNS Answer section of the provided Msg in ExtractedAnswer type.
type ResolveError ¶
ResolveError contains the Rcode returned during the DNS query.
func (*ResolveError) Error ¶
func (e *ResolveError) Error() string
type Resolver ¶
type Resolver interface { fmt.Stringer // Stop will stop the Resolver. Stop() // Stopped returns true if the Resolver is already stopped. Stopped() bool // Query performs a DNS query for the provided name and message type. Query(ctx context.Context, msg *dns.Msg, priority int, retry Retry) (*dns.Msg, error) // WildcardType returns the DNS wildcard type for the FQDN in the provided message. WildcardType(ctx context.Context, msg *dns.Msg, domain string) int }
Resolver performs DNS resolutions.
func NewBaseResolver ¶
NewBaseResolver initializes a Resolver that sends DNS queries to the provided IP address.