udp

package
v0.0.0-...-bcd5820 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// DestinationPort is the port to which messages are sent (usually 53)
	DestinationPort uint16

	// ReceiveTimeout is the time after which a message exchange times out
	ReceiveTimeout time.Duration

	// WriteTimeout is the timeout after which write operations fail.
	WriteTimeout time.Duration
	// contains filtered or unexported fields
}

Client is a DNS client that exchanges UDP messages

func NewClient

func NewClient(poolV4 ConnFactory, poolV6 ConnFactory, udpTimeout time.Duration, udpSize uint16) *Client

func (*Client) Enqueue

func (c *Client) Enqueue(correlationId uuid.UUID, q client.Question, ip client.Address, sendOpts client.SendOpts)

func (*Client) ResponseChan

func (c *Client) ResponseChan() <-chan client.Response

type ConnFactory

type ConnFactory interface {
	GetOrCreate(onReceive ReceiveCallback) (*PooledConn, error)
}

ConnFactory manages connections (e.g. a connection pool)

type Pool

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

func NewPool

func NewPool(localIP net.IP, udpSize uint16, poolSize uint16) *Pool

func (*Pool) GetOrCreate

func (pool *Pool) GetOrCreate(onReceive ReceiveCallback) (*PooledConn, error)

type PooledConn

type PooledConn struct {
	*internal.MessageIdGenerator

	Id uuid.UUID

	IsIPV6 bool
	// contains filtered or unexported fields
}

PooledConn is a wrapper around connection stored in the UDP connection pool.

func (*PooledConn) Close

func (conn *PooledConn) Close()

func (*PooledConn) ID

func (conn *PooledConn) ID() uuid.UUID

func (*PooledConn) IsFaulty

func (conn *PooledConn) IsFaulty() bool

func (*PooledConn) StartReceiving

func (conn *PooledConn) StartReceiving(onReceive ReceiveCallback)

func (*PooledConn) WriteMessageTo

func (conn *PooledConn) WriteMessageTo(msg *dns.Msg, remoteIP client.Address, remotePort uint16, timeout time.Duration) error

type ReceiveCallback

type ReceiveCallback func(uuid.UUID, *dns.Msg, string, error)

Jump to

Keyboard shortcuts

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