Documentation ¶
Index ¶
- Constants
- func NsecTraversal(domain, server string) ([]*requests.DNSRequest, error)
- func RemoveLastDot(name string) string
- func UnlikelyName(sub string) string
- func ZoneTransfer(sub, domain, server string) ([]*requests.DNSRequest, error)
- type BaseResolver
- func (r *BaseResolver) Address() string
- func (r *BaseResolver) Available() (bool, error)
- func (r *BaseResolver) GetWildcardType(ctx context.Context, req *requests.DNSRequest) int
- func (r *BaseResolver) IsStopped() bool
- func (r *BaseResolver) MatchesWildcard(ctx context.Context, req *requests.DNSRequest) bool
- func (r *BaseResolver) Port() int
- func (r *BaseResolver) ReportError()
- func (r *BaseResolver) Resolve(ctx context.Context, name, qtype string, priority int) ([]requests.DNSAnswer, bool, error)
- func (r *BaseResolver) Reverse(ctx context.Context, addr string, priority int) (string, string, error)
- func (r *BaseResolver) Stats() map[int]int64
- func (r *BaseResolver) Stop() error
- func (r *BaseResolver) SubdomainToDomain(name string) string
- func (r *BaseResolver) WipeStats()
- type RateMonitoredResolver
- func (r *RateMonitoredResolver) Address() string
- func (r *RateMonitoredResolver) Available() (bool, error)
- func (r *RateMonitoredResolver) GetWildcardType(ctx context.Context, req *requests.DNSRequest) int
- func (r *RateMonitoredResolver) IsStopped() bool
- func (r *RateMonitoredResolver) MatchesWildcard(ctx context.Context, req *requests.DNSRequest) bool
- func (r *RateMonitoredResolver) Port() int
- func (r *RateMonitoredResolver) ReportError()
- func (r *RateMonitoredResolver) Resolve(ctx context.Context, name, qtype string, priority int) ([]requests.DNSAnswer, bool, error)
- func (r *RateMonitoredResolver) Reverse(ctx context.Context, addr string, priority int) (string, string, error)
- func (r *RateMonitoredResolver) Stats() map[int]int64
- func (r *RateMonitoredResolver) Stop() error
- func (r *RateMonitoredResolver) SubdomainToDomain(name string) string
- func (r *RateMonitoredResolver) WipeStats()
- type ResolveError
- type Resolver
- type ResolverPool
- func (rp *ResolverPool) Address() string
- func (rp *ResolverPool) Available() (bool, error)
- func (rp *ResolverPool) GetWildcardType(ctx context.Context, req *requests.DNSRequest) int
- func (rp *ResolverPool) IsStopped() bool
- func (rp *ResolverPool) MatchesWildcard(ctx context.Context, req *requests.DNSRequest) bool
- func (rp *ResolverPool) NextResolver() Resolver
- func (rp *ResolverPool) Port() int
- func (rp *ResolverPool) ReportError()
- func (rp *ResolverPool) Resolve(ctx context.Context, name, qtype string, priority int) ([]requests.DNSAnswer, bool, error)
- func (rp *ResolverPool) Reverse(ctx context.Context, addr string, priority int) (string, string, error)
- func (rp *ResolverPool) SanityChecks()
- func (rp *ResolverPool) Stats() map[int]int64
- func (rp *ResolverPool) Stop() error
- func (rp *ResolverPool) SubdomainToDomain(name string) string
- func (rp *ResolverPool) WipeStats()
- type ScoredResolver
- func (r *ScoredResolver) Address() string
- func (r *ScoredResolver) Available() (bool, error)
- func (r *ScoredResolver) GetWildcardType(ctx context.Context, req *requests.DNSRequest) int
- func (r *ScoredResolver) IsStopped() bool
- func (r *ScoredResolver) MatchesWildcard(ctx context.Context, req *requests.DNSRequest) bool
- func (r *ScoredResolver) Port() int
- func (r *ScoredResolver) ReportError()
- func (r *ScoredResolver) Resolve(ctx context.Context, name, qtype string, priority int) ([]requests.DNSAnswer, bool, error)
- func (r *ScoredResolver) Reverse(ctx context.Context, addr string, priority int) (string, string, error)
- func (r *ScoredResolver) Stats() map[int]int64
- func (r *ScoredResolver) Stop() error
- func (r *ScoredResolver) SubdomainToDomain(name string) string
- func (r *ScoredResolver) WipeStats()
Constants ¶
const ( PriorityLow int = iota PriorityHigh PriorityCritical )
The priority levels for DNS resolution.
const ( QueryAttempts = 64 QueryTimeout = 65 QueryRTT = 66 QueryCompleted = 67 )
Index values into the Resolver.Stats map.
const ( // CurrentScore is an index value into the ScoredResolver.Stats map. CurrentScore = 128 // PassingScore is the minimum score required to continue use of the Resolver. PassingScore = 50 )
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 (
// CurrentRate is an index value into the RateLimitedResolver.Stats map
CurrentRate = 256
)
const NotAvailableRcode = 256
NotAvailableRcode is our made up rcode to indicate an availability problem.
Variables ¶
This section is empty.
Functions ¶
func NsecTraversal ¶
func NsecTraversal(domain, server string) ([]*requests.DNSRequest, error)
NsecTraversal attempts to retrieve a DNS zone using NSEC-walking.
func RemoveLastDot ¶
RemoveLastDot removes the '.' at the end of the provided FQDN.
func UnlikelyName ¶
UnlikelyName takes a subdomain name and returns an unlikely DNS name within that subdomain.
func ZoneTransfer ¶
func ZoneTransfer(sub, domain, server string) ([]*requests.DNSRequest, error)
ZoneTransfer attempts a DNS zone transfer using the server identified in the parameters. The returned slice contains all the records discovered from the zone transfer.
Types ¶
type BaseResolver ¶
type BaseResolver struct { sync.RWMutex Done chan struct{} WindowDuration time.Duration CurrentConn net.Conn LastConn net.Conn // contains filtered or unexported fields }
BaseResolver performs DNS queries on a single resolver at high-performance.
func NewBaseResolver ¶
func NewBaseResolver(addr string) *BaseResolver
NewBaseResolver initializes a Resolver that send DNS queries to the provided IP address.
func (*BaseResolver) Address ¶
func (r *BaseResolver) Address() string
Address implements the Resolver interface.
func (*BaseResolver) Available ¶
func (r *BaseResolver) Available() (bool, error)
Available always returns true.
func (*BaseResolver) GetWildcardType ¶
func (r *BaseResolver) GetWildcardType(ctx context.Context, req *requests.DNSRequest) int
GetWildcardType returns the DNS wildcard type for the provided subdomain name.
func (*BaseResolver) IsStopped ¶
func (r *BaseResolver) IsStopped() bool
IsStopped implements the Resolver interface.
func (*BaseResolver) MatchesWildcard ¶
func (r *BaseResolver) MatchesWildcard(ctx context.Context, req *requests.DNSRequest) bool
MatchesWildcard returns true if the request provided resolved to a DNS wildcard.
func (*BaseResolver) Port ¶
func (r *BaseResolver) Port() int
Port implements the Resolver interface.
func (*BaseResolver) ReportError ¶
func (r *BaseResolver) ReportError()
ReportError indicates to the Resolver that it delivered an erroneos response.
func (*BaseResolver) Resolve ¶
func (r *BaseResolver) Resolve(ctx context.Context, name, qtype string, priority int) ([]requests.DNSAnswer, bool, error)
Resolve performs DNS queries using the Resolver.
func (*BaseResolver) Reverse ¶
func (r *BaseResolver) Reverse(ctx context.Context, addr string, priority int) (string, string, error)
Reverse is performs reverse DNS queries using the Resolver.
func (*BaseResolver) Stats ¶
func (r *BaseResolver) Stats() map[int]int64
Stats returns performance counters.
func (*BaseResolver) Stop ¶
func (r *BaseResolver) Stop() error
Stop causes the Resolver to stop sending DNS queries and closes the network connection.
func (*BaseResolver) SubdomainToDomain ¶
func (r *BaseResolver) SubdomainToDomain(name string) string
SubdomainToDomain returns the first subdomain name of the provided parameter that responds to a DNS query for the NS record type.
func (*BaseResolver) WipeStats ¶
func (r *BaseResolver) WipeStats()
WipeStats clears the performance counters.
type RateMonitoredResolver ¶
type RateMonitoredResolver struct { sync.RWMutex Done chan struct{} // contains filtered or unexported fields }
RateMonitoredResolver performs DNS queries on a single resolver at the rate it can handle.
func NewRateMonitoredResolver ¶
func NewRateMonitoredResolver(res Resolver) *RateMonitoredResolver
NewRateMonitoredResolver initializes a Resolver that scores the performance of the DNS server.
func (*RateMonitoredResolver) Address ¶
func (r *RateMonitoredResolver) Address() string
Address implements the Resolver interface.
func (*RateMonitoredResolver) Available ¶
func (r *RateMonitoredResolver) Available() (bool, error)
Available returns true if the Resolver can handle another DNS request.
func (*RateMonitoredResolver) GetWildcardType ¶
func (r *RateMonitoredResolver) GetWildcardType(ctx context.Context, req *requests.DNSRequest) int
GetWildcardType returns the DNS wildcard type for the provided subdomain name.
func (*RateMonitoredResolver) IsStopped ¶
func (r *RateMonitoredResolver) IsStopped() bool
IsStopped implements the Resolver interface.
func (*RateMonitoredResolver) MatchesWildcard ¶
func (r *RateMonitoredResolver) MatchesWildcard(ctx context.Context, req *requests.DNSRequest) bool
MatchesWildcard returns true if the request provided resolved to a DNS wildcard.
func (*RateMonitoredResolver) Port ¶
func (r *RateMonitoredResolver) Port() int
Port implements the Resolver interface.
func (*RateMonitoredResolver) ReportError ¶
func (r *RateMonitoredResolver) ReportError()
ReportError indicates to the Resolver that it delivered an erroneos response.
func (*RateMonitoredResolver) Resolve ¶
func (r *RateMonitoredResolver) Resolve(ctx context.Context, name, qtype string, priority int) ([]requests.DNSAnswer, bool, error)
Resolve implements the Resolver interface.
func (*RateMonitoredResolver) Reverse ¶
func (r *RateMonitoredResolver) Reverse(ctx context.Context, addr string, priority int) (string, string, error)
Reverse implements the Resolver interface.
func (*RateMonitoredResolver) Stats ¶
func (r *RateMonitoredResolver) Stats() map[int]int64
Stats returns performance counters.
func (*RateMonitoredResolver) Stop ¶
func (r *RateMonitoredResolver) Stop() error
Stop causes the Resolver to stop.
func (*RateMonitoredResolver) SubdomainToDomain ¶
func (r *RateMonitoredResolver) SubdomainToDomain(name string) string
SubdomainToDomain returns the first subdomain name of the provided parameter that responds to a DNS query for the NS record type.
func (*RateMonitoredResolver) WipeStats ¶
func (r *RateMonitoredResolver) WipeStats()
WipeStats clears the performance counters.
type ResolveError ¶
ResolveError contains the Rcode returned during the DNS query.
func (*ResolveError) Error ¶
func (e *ResolveError) Error() string
type Resolver ¶
type Resolver interface { // Address returns the IP address where the resolver is located Address() string // Port returns the port number used to communicate with the resolver Port() int // Resolve performs DNS queries using the Resolver Resolve(ctx context.Context, name, qtype string, priority int) ([]requests.DNSAnswer, bool, error) // Reverse is performs reverse DNS queries using the Resolver Reverse(ctx context.Context, addr string, priority int) (string, string, error) // Available returns true if the Resolver can handle another DNS request Available() (bool, error) // Stats returns performance counters Stats() map[int]int64 WipeStats() // ReportError indicates to the Resolver that it delivered an erroneos response ReportError() // MatchesWildcard returns true if the request provided resolved to a DNS wildcard MatchesWildcard(ctx context.Context, req *requests.DNSRequest) bool // GetWildcardType returns the DNS wildcard type for the provided subdomain name GetWildcardType(ctx context.Context, req *requests.DNSRequest) int // SubdomainToDomain returns the first subdomain name of the provided // parameter that responds to a DNS query for the NS record type SubdomainToDomain(name string) string // Stop the Resolver Stop() error IsStopped() bool }
Resolver is the object type for performing DNS resolutions.
type ResolverPool ¶
type ResolverPool struct { Resolvers []Resolver Done chan struct{} // Logger for error messages Log *log.Logger // contains filtered or unexported fields }
ResolverPool manages many DNS resolvers for high-performance use, such as brute forcing attacks.
func NewResolverPool ¶
func NewResolverPool(res []Resolver, logger *log.Logger) *ResolverPool
NewResolverPool initializes a ResolverPool that uses the provided Resolvers.
func SetupResolverPool ¶
func SetupResolverPool(addrs []string, scoring, ratemon bool, log *log.Logger) *ResolverPool
SetupResolverPool initializes a ResolverPool with the type of resolvers indicated by the parameters.
func (*ResolverPool) Address ¶
func (rp *ResolverPool) Address() string
Address implements the Resolver interface.
func (*ResolverPool) Available ¶
func (rp *ResolverPool) Available() (bool, error)
Available returns true if the Resolver can handle another DNS request.
func (*ResolverPool) GetWildcardType ¶
func (rp *ResolverPool) GetWildcardType(ctx context.Context, req *requests.DNSRequest) int
GetWildcardType returns the DNS wildcard type for the provided subdomain name.
func (*ResolverPool) IsStopped ¶
func (rp *ResolverPool) IsStopped() bool
IsStopped implements the Resolver interface.
func (*ResolverPool) MatchesWildcard ¶
func (rp *ResolverPool) MatchesWildcard(ctx context.Context, req *requests.DNSRequest) bool
MatchesWildcard returns true if the request provided resolved to a DNS wildcard.
func (*ResolverPool) NextResolver ¶
func (rp *ResolverPool) NextResolver() Resolver
NextResolver returns a randomly selected Resolver from the pool that has availability.
func (*ResolverPool) Port ¶
func (rp *ResolverPool) Port() int
Port implements the Resolver interface.
func (*ResolverPool) ReportError ¶
func (rp *ResolverPool) ReportError()
ReportError implements the Resolver interface.
func (*ResolverPool) Resolve ¶
func (rp *ResolverPool) Resolve(ctx context.Context, name, qtype string, priority int) ([]requests.DNSAnswer, bool, error)
Resolve performs a DNS request using available Resolvers in the pool.
func (*ResolverPool) Reverse ¶
func (rp *ResolverPool) Reverse(ctx context.Context, addr string, priority int) (string, string, error)
Reverse is performs reverse DNS queries using available Resolvers in the pool.
func (*ResolverPool) SanityChecks ¶
func (rp *ResolverPool) SanityChecks()
SanityChecks performs some basic checks to see if the resolvers are reliable.
func (*ResolverPool) Stats ¶
func (rp *ResolverPool) Stats() map[int]int64
Stats returns performance counters.
func (*ResolverPool) Stop ¶
func (rp *ResolverPool) Stop() error
Stop calls the Stop method for each Resolver object in the pool.
func (*ResolverPool) SubdomainToDomain ¶
func (rp *ResolverPool) SubdomainToDomain(name string) string
SubdomainToDomain returns the first subdomain name of the provided parameter that responds to a DNS query for the NS record type.
func (*ResolverPool) WipeStats ¶
func (rp *ResolverPool) WipeStats()
WipeStats clears the performance counters.
type ScoredResolver ¶
ScoredResolver performs DNS queries on a single resolver and maintains a performance score.
func NewScoredResolver ¶
func NewScoredResolver(res Resolver) *ScoredResolver
NewScoredResolver initializes a Resolver that scores the performance of the DNS server.
func (*ScoredResolver) Address ¶
func (r *ScoredResolver) Address() string
Address implements the Resolver interface.
func (*ScoredResolver) Available ¶
func (r *ScoredResolver) Available() (bool, error)
Available returns true if the Resolver can handle another DNS request.
func (*ScoredResolver) GetWildcardType ¶
func (r *ScoredResolver) GetWildcardType(ctx context.Context, req *requests.DNSRequest) int
GetWildcardType returns the DNS wildcard type for the provided subdomain name.
func (*ScoredResolver) IsStopped ¶
func (r *ScoredResolver) IsStopped() bool
IsStopped implements the Resolver interface.
func (*ScoredResolver) MatchesWildcard ¶
func (r *ScoredResolver) MatchesWildcard(ctx context.Context, req *requests.DNSRequest) bool
MatchesWildcard returns true if the request provided resolved to a DNS wildcard.
func (*ScoredResolver) Port ¶
func (r *ScoredResolver) Port() int
Port implements the Resolver interface.
func (*ScoredResolver) ReportError ¶
func (r *ScoredResolver) ReportError()
ReportError indicates to the Resolver that it delivered an erroneos response.
func (*ScoredResolver) Resolve ¶
func (r *ScoredResolver) Resolve(ctx context.Context, name, qtype string, priority int) ([]requests.DNSAnswer, bool, error)
Resolve implements the Resolver interface.
func (*ScoredResolver) Reverse ¶
func (r *ScoredResolver) Reverse(ctx context.Context, addr string, priority int) (string, string, error)
Reverse implements the Resolver interface.
func (*ScoredResolver) Stats ¶
func (r *ScoredResolver) Stats() map[int]int64
Stats returns performance counters.
func (*ScoredResolver) Stop ¶
func (r *ScoredResolver) Stop() error
Stop causes the Resolver to stop.
func (*ScoredResolver) SubdomainToDomain ¶
func (r *ScoredResolver) SubdomainToDomain(name string) string
SubdomainToDomain returns the first subdomain name of the provided parameter that responds to a DNS query for the NS record type.
func (*ScoredResolver) WipeStats ¶
func (r *ScoredResolver) WipeStats()
WipeStats clears the performance counters.