dnsclient

package
v0.0.0-...-72c2bb7 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoResponse Returned when there was no response
	ErrNoResponse = errors.New("error getting valid response")
	// ErrEmptyRecords returned when there were no records returned
	ErrEmptyRecords = errors.New("error empty record returned")
	// ErrRcode when Rcode != dns.RcodeSuccess
	ErrRcode = errors.New("bad Rcode returned by server")
	// ErrInvalidIP when IP is not properly formed
	ErrInvalidIP = errors.New("invalid format for IP address")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client to resolve hosts and ip addresses

func New

func New(servers []string, retry int) *Client

New returns a new DNS client

func (*Client) DoAXFR

func (c *Client) DoAXFR(ctx context.Context, name string) (map[string][]*Results, error)

DoAXFR attempts to execute an AXFR against a domain by first getting the domains NS records, and attempts an AXFR against each server. We use a waitgroup for NS servers and a workerpool for doing resolution on various records returned by AXFR.

func (*Client) DoNSECWalk

func (c *Client) DoNSECWalk(ctx context.Context, domain string) (map[string]struct{}, error)

DoNSECWalk walks NSEC records, following NextDomain until it's empty, or points back to the original starting address.

func (*Client) IsWildcard

func (c *Client) IsWildcard(ctx context.Context, domain string) bool

IsWildcard tests if a domain is a wildcard domain, attempt 10 A and 10 AAAA queries of randomly generated names, if we get even a single response it's probably a wildcard

func (*Client) LookupMX

func (c *Client) LookupMX(ctx context.Context, zone string) (*Results, error)

LookupMX returns MX RRs for a zone

func (*Client) LookupNS

func (c *Client) LookupNS(ctx context.Context, zone string) (*Results, error)

LookupNS returns NS RRs for a zone

func (*Client) LookupSRV

func (c *Client) LookupSRV(ctx context.Context, zone string) (*Results, error)

LookupSRV returns SRV RRs for a zone

func (*Client) ResolveIP

func (c *Client) ResolveIP(ctx context.Context, ip string) (*Results, error)

ResolveIP returns RRs for an IP address by parsing IP type and calling ipv4 or ipv6

func (*Client) ResolveName

func (c *Client) ResolveName(ctx context.Context, name string) ([]*Results, error)

ResolveName attempts to resolve a name to ip addresses. It will attempt to resolve both IPv4 and IPv6 addresses to the name

type Results

type Results struct {
	IPs         []string // a slice of ip addresses returned from a request
	Hosts       []string // a slice of hosts returned from a request
	RecordType  uint16   // records returned
	RequestType uint16   // where these results came from (TypeA, TypeAAAA etc)
}

Results holds results of a lookup

func (*Results) Type

func (r *Results) Type() string

Type returns a string representation of the record type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL