client

package
v0.0.0-...-b888a31 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressAttempt

type AddressAttempt struct {
	Addresss   []string
	RetryCount uint8
}

AddressAttempt stores resolved address and retry count if it's unresolved

type Client

type Client struct {
	dns.Client
	DCache DelegationCache
	LCache LookupCache
	// contains filtered or unexported fields
}

Client is a DNS client capable of performing parallel requests.

func New

func New(maxRetryCount uint8) Client

New creates a new Client.

func (*Client) ParallelQuery

func (c *Client) ParallelQuery(m *dns.Msg, servers []Server) Responses

ParallelQuery perform an exchange using m with all servers in parallel and return all responses.

func (*Client) RecursiveQuery

func (c *Client) RecursiveQuery(m *dns.Msg, tracer Tracer) (r *dns.Msg, rtt time.Duration, err error)

RecursiveQuery performs a recursive query by querying all the available name servers to gather statistics. nolint: funlen,gocyclo,gocognit,nonamedreturns,varnamelen

type DelegationCache

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

DelegationCache store and retrive delegations.

func (*DelegationCache) Add

func (d *DelegationCache) Add(domain string, server Server) bool

Add adds a server as a delegation for domain. If addrs is not specified, server will be looked up. Returns false if already there

func (*DelegationCache) Get

func (d *DelegationCache) Get(domain string) (label string, servers []Server)

Get returns the most specific name servers for domain with its matching label.

type LookupCache

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

LookupCache stores mixed lookup results for A and AAAA records of labels with not support of TTL.

func (*LookupCache) Get

func (c *LookupCache) Get(label string) AddressAttempt

Get retrieve the saved address or the attempt

func (*LookupCache) IncAttempt

func (c *LookupCache) IncAttempt(label string)

IncAttempt increase attempt to recursive resolve the address

func (*LookupCache) Set

func (c *LookupCache) Set(label string, addrs []string)

type Response

type Response struct {
	Server Server
	Addr   string
	Msg    *dns.Msg
	RTT    time.Duration
	Err    error
}

Response stores a DNS response.

type ResponseType

type ResponseType int
const (
	ResponseTypeUnknown ResponseType = iota
	ResponseTypeDelegation
	ResponseTypeCNAME
	ResponseTypeFinal
)

type Responses

type Responses []Response

func (Responses) Fastest

func (rs Responses) Fastest() *Response

Fastest returns the fastest success response or nil.

type Server

type Server struct {
	Name      string
	HasGlue   bool
	TTL       uint32
	Addrs     []string
	LookupRTT time.Duration
	LookupErr error
}

Server is a name server hostname with associated IP addresses.

func (Server) String

func (s Server) String() string

type Tracer

type Tracer struct {
	GotIntermediaryResponse func(i int, m *dns.Msg, rs Responses, rtype ResponseType)
	FollowingCNAME          func(domain, target string)
}

Jump to

Keyboard shortcuts

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