retryabledns

package module
v0.0.0-...-332ba8e Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 18 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckInternalIPs = false

CheckInternalIPs when set to true returns if DNS response IPs belong to internal IP ranges.

View Source
var RootDNSServers = []RootDNS{
	{"a.root-servers.net", "198.41.0.4", "2001:503:ba3e::2:30", "Verisign, Inc"},
	{"b.root-servers.net", "199.9.14.201", "2001:500:200::b", "University of Southern California, Information Sciences Institute"},
	{"c.root-servers.net", "192.33.4.12", "2001:500:2::c", "Cogent Communications"},
	{"d.root-servers.net", "199.7.91.13", "2001:500:2d::d", "University of Maryland"},
	{"e.root-servers.net", "192.203.230.10", "2001:500:a8::e", "NASA (Ames Research Center)"},
	{"f.root-servers.net", "192.5.5.241", "2001:500:2f::f", "Internet Systems Consortium, Inc."},
	{"g.root-servers.net", "192.112.36.4", "2001:500:12::d0d", "US Department of Defense (NIC)"},
	{"h.root-servers.net", "198.97.190.53", "2001:500:1::53", "US Army (Research Lab)"},
	{"i.root-servers.net", "192.36.148.17", "2001:7fe::53", "Netnod"},
	{"j.root-servers.net", "192.58.128.30", "2001:503:c27::2:30", "Verisign, Inc"},
	{"k.root-servers.net", "193.0.14.129", "2001:7fd::1", "RIPE NCC"},
	{"l.root-servers.net", "199.7.83.42", "2001:500:9f::42", "ICANN"},
	{"m.root-servers.net", "202.12.27.33", "2001:dc3::35", "WIDE Project"},
}
View Source
var RootDNSServersIPv4 = []string{
	"198.41.0.4:53", "199.9.14.201:53", "192.33.4.12:53", "199.7.91.13:53",
	"192.203.230.10:53", "192.5.5.241:53", "192.112.36.4:53", "198.97.190.53:53",
	"192.36.148.17:53", "192.58.128.30:53", "193.0.14.129:53", "199.7.83.42:53",
	"202.12.27.33:53",
}

Functions

This section is empty.

Types

type AXFRData

type AXFRData struct {
	Host    string     `json:"host,omitempty"`
	DNSData []*DNSData `json:"chain,omitempty"`
}

type Client

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

Client is a DNS resolver client to resolve hostnames.

func New

func New(baseResolvers []string, maxRetries int) (*Client, error)

New creates a new dns client

func NewWithOptions

func NewWithOptions(options Options) (*Client, error)

New creates a new dns client with options

func (*Client) A

func (c *Client) A(host string) (*DNSData, error)

A helper function

func (*Client) AAAA

func (c *Client) AAAA(host string) (*DNSData, error)

AAAA helper function

func (*Client) AXFR

func (c *Client) AXFR(host string) (*AXFRData, error)

func (*Client) CAA

func (c *Client) CAA(host string) (*DNSData, error)

CAA helper function

func (*Client) CNAME

func (c *Client) CNAME(host string) (*DNSData, error)

CNAME helper function

func (*Client) Do

func (c *Client) Do(msg *dns.Msg) (*dns.Msg, error)

Do sends a provided dns request and return the raw native response

func (*Client) MX

func (c *Client) MX(host string) (*DNSData, error)

MX helper function

func (*Client) NS

func (c *Client) NS(host string) (*DNSData, error)

NS helper function

func (*Client) PTR

func (c *Client) PTR(host string) (*DNSData, error)

PTR helper function

func (*Client) Query

func (c *Client) Query(host string, requestType uint16) (*DNSData, error)

Query sends a provided dns request and return enriched response

func (*Client) QueryMultiple

func (c *Client) QueryMultiple(host string, requestTypes []uint16) (*DNSData, error)

QueryMultiple sends a provided dns request and return the data

func (*Client) QueryMultipleWithResolver

func (c *Client) QueryMultipleWithResolver(host string, requestTypes []uint16, resolver Resolver) (*DNSData, error)

QueryMultiple sends a provided dns request and return the data with a specific resolver

func (*Client) QueryParallel

func (c *Client) QueryParallel(host string, requestType uint16, resolvers []string) ([]*DNSData, error)

QueryParallel sends a provided dns request to multiple resolvers in parallel

func (*Client) Resolve

func (c *Client) Resolve(host string) (*DNSData, error)

Resolve is the underlying resolve function that actually resolves a host and gets the ip records for that host.

func (*Client) ResolveWithSyscall

func (c *Client) ResolveWithSyscall(host string) (*DNSData, error)

ResolveWithSyscall attempts to resolve the host through system calls

func (*Client) SOA

func (c *Client) SOA(host string) (*DNSData, error)

SOA helper function

func (*Client) SRV

func (c *Client) SRV(host string) (*DNSData, error)

SRV helper function

func (*Client) TXT

func (c *Client) TXT(host string) (*DNSData, error)

TXT helper function

func (*Client) Trace

func (c *Client) Trace(host string, requestType uint16, maxrecursion int) (*TraceData, error)

Trace the requested domain with the provided query type

type DNSData

type DNSData struct {
	Host           string     `json:"host,omitempty"`
	TTL            int        `json:"ttl,omitempty"`
	Resolver       []string   `json:"resolver,omitempty"`
	A              []string   `json:"a,omitempty"`
	AAAA           []string   `json:"aaaa,omitempty"`
	CNAME          []string   `json:"cname,omitempty"`
	MX             []string   `json:"mx,omitempty"`
	PTR            []string   `json:"ptr,omitempty"`
	SOA            []string   `json:"soa,omitempty"`
	NS             []string   `json:"ns,omitempty"`
	TXT            []string   `json:"txt,omitempty"`
	SRV            []string   `json:"srv,omitempty"`
	CAA            []string   `json:"caa,omitempty"`
	AllRecords     []string   `json:"all,omitempty"`
	Raw            string     `json:"raw,omitempty"`
	HasInternalIPs bool       `json:"has_internal_ips,omitempty"`
	InternalIPs    []string   `json:"internal_ips,omitempty"`
	StatusCode     string     `json:"status_code,omitempty"`
	StatusCodeRaw  int        `json:"status_code_raw,omitempty"`
	TraceData      *TraceData `json:"trace,omitempty"`
	AXFRData       *AXFRData  `json:"axfr,omitempty"`
	RawResp        *dns.Msg   `json:"raw_resp,omitempty"`
	Timestamp      time.Time  `json:"timestamp,omitempty"`
	HostsFile      bool       `json:"hosts_file,omitempty"`
}

DNSData is the data for a DNS request response

func (*DNSData) JSON

func (d *DNSData) JSON() (string, error)

JSON returns the object as json string

func (*DNSData) Marshal

func (d *DNSData) Marshal() ([]byte, error)

Marshal encodes the dnsdata to a binary representation

func (*DNSData) ParseFromEnvelopeChan

func (d *DNSData) ParseFromEnvelopeChan(envChan chan *dns.Envelope) error

func (*DNSData) ParseFromMsg

func (d *DNSData) ParseFromMsg(msg *dns.Msg) error

ParseFromMsg and enrich data

func (*DNSData) ParseFromRR

func (d *DNSData) ParseFromRR(rrs []dns.RR) error

func (*DNSData) Unmarshal

func (d *DNSData) Unmarshal(b []byte) error

Unmarshal decodes the dnsdata from a binary representation

type DohProtocol

type DohProtocol string
const (
	JsonAPI DohProtocol = "jsonapi"
	GET     DohProtocol = "get"
	POST    DohProtocol = "post"
)

func (DohProtocol) String

func (p DohProtocol) String() string

func (DohProtocol) StringWithSemicolon

func (p DohProtocol) StringWithSemicolon() string

type DohResolver

type DohResolver struct {
	Protocol DohProtocol
	URL      string
}

func (DohResolver) Method

func (r DohResolver) Method() string

func (DohResolver) String

func (r DohResolver) String() string

type NetworkResolver

type NetworkResolver struct {
	Protocol Protocol
	Host     string
	Port     string
}

func (NetworkResolver) String

func (r NetworkResolver) String() string

type Options

type Options struct {
	BaseResolvers []string
	MaxRetries    int
	Timeout       time.Duration
	Hostsfile     bool
}

func (*Options) Validate

func (options *Options) Validate() error

type Protocol

type Protocol string
const (
	UDP Protocol = "udp"
	TCP Protocol = "tcp"
	DOH Protocol = "doh"
	DOT Protocol = "dot"
)

func (Protocol) String

func (p Protocol) String() string

func (Protocol) StringWithSemicolon

func (p Protocol) StringWithSemicolon() string

type Resolver

type Resolver interface {
	String() string
}

type RootDNS

type RootDNS struct {
	Host     string
	IPv4     string
	IPv6     string
	Operator string
}

type TraceData

type TraceData struct {
	Host    string     `json:"host,omitempty"`
	DNSData []*DNSData `json:"chain,omitempty"`
}

TraceData contains the trace information for a dns query

Directories

Path Synopsis
Package mapcidr implements methods to allow working with CIDRs.
Package mapcidr implements methods to allow working with CIDRs.

Jump to

Keyboard shortcuts

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