client

package
v0.0.0-...-5abfbfe Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package client provides a DNS client to send and receive DNS messages

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidNetwork  = errors.New("invalid network")
	ErrNoMatchHeaderID = errors.New("header ids don't match")
)

Functions

This section is empty.

Types

type Client

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

Client is the default DNS client to query and retrieve DNS messages

func New

func New(l *logger.Logger) *Client

func (*Client) Configure

func (c *Client) Configure(opts ...OptionFunc) error

Configure configures available client options

func (*Client) Dial

func (c *Client) Dial(network string, addr netip.AddrPort) (net.Conn, error)

func (*Client) GetID

func (c *Client) GetID() uint16

GetID returns the current header ID and generates a new one

func (*Client) Query

func (c *Client) Query(name string, class, t uint16, addr netip.Addr) (*dns.Message, error)

Query sends a DNS query for 'name' with 'class' and 'type' to the remote DNS server with 'ip' and returns the answer message and any encountered error

func (*Client) QueryTCP

func (c *Client) QueryTCP(query *dns.Message, addrPort netip.AddrPort) (*dns.Message, error)

QueryTCP sends a DNS 'query' to target DNS server with 'ip' using TCP

func (*Client) QueryUDP

func (c *Client) QueryUDP(query *dns.Message, addrPort netip.AddrPort) (*dns.Message, error)

QueryUDP sends a DNS 'query' to a remote DNS server with 'ip' using UDP

type OptionFunc

type OptionFunc func(*Client) error

func WithDialTimeout

func WithDialTimeout(timeout time.Duration) OptionFunc

func WithNetwork

func WithNetwork(network string) OptionFunc

func WithReadTimeout

func WithReadTimeout(timeout time.Duration) OptionFunc

func WithWriteTimeout

func WithWriteTimeout(timeout time.Duration) OptionFunc

Jump to

Keyboard shortcuts

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