transport

package
v0.0.0-...-264f9d0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClosedTransport = errors.New("transport has been closed")
	ErrPayloadTooSmall = errors.New("payload is too small")
	ErrPayloadOverFlow = errors.New("payload is too large")
	ErrIdleTimeOut     = errors.New("idle timeout")
)

Functions

This section is empty.

Types

type DoHTransport

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

DoHTransport is a DNS-over-HTTPS (RFC 8484) upstream using GET method.

func NewDoHTransport

func NewDoHTransport(opts DoHTransportOpts) (*DoHTransport, error)

func (*DoHTransport) Close

func (u *DoHTransport) Close() error

func (*DoHTransport) ExchangeContext

func (u *DoHTransport) ExchangeContext(ctx context.Context, q []byte) (*dnsmsg.Msg, error)

type DoHTransportOpts

type DoHTransportOpts struct {
	EndPointUrl  string
	RoundTripper http.RoundTripper
	Closer       io.Closer
	Logger       *zerolog.Logger
}

type PipelineOpts

type PipelineOpts struct {
	// DialContext specifies the method to dial a connection to the server.
	// DialContext MUST NOT be nil.
	DialContext func(ctx context.Context) (net.Conn, error)

	// DialTimeout specifies the timeout for DialFunc.
	// Default is defaultDialTimeout.
	DialTimeout time.Duration

	// Set to true if underlayer is TCP. Which needs a 2 bytes length header.
	IsTCP bool

	// IdleTimeout controls the maximum idle time for each connection.
	// Default is defaultIdleTimeout.
	IdleTimeout time.Duration

	// MaxConcurrentQuery limits the number of maximum concurrent queries
	// in the connection. Default is defaultPipelineMaxConcurrent.
	MaxConcurrentQuery int

	Logger *zerolog.Logger
}

type PipelineTransport

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

PipelineTransport will pipeline queries as RFC 7766 6.2.1.1 suggested. It also can reuse udp socket. Since dns over udp is some kind of "pipeline".

func NewPipelineTransport

func NewPipelineTransport(opts PipelineOpts) *PipelineTransport

func (*PipelineTransport) Close

func (t *PipelineTransport) Close() error

Close closes PipelineTransport and all its connections. It always returns a nil error.

func (*PipelineTransport) ExchangeContext

func (t *PipelineTransport) ExchangeContext(ctx context.Context, m []byte) (*dnsmsg.Msg, error)

type QuicTransport

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

func NewQuicTransport

func NewQuicTransport(opts QuicTransportOpts) *QuicTransport

func (*QuicTransport) Close

func (t *QuicTransport) Close() error

func (*QuicTransport) ExchangeContext

func (t *QuicTransport) ExchangeContext(ctx context.Context, q []byte) (*dnsmsg.Msg, error)

type QuicTransportOpts

type QuicTransportOpts struct {
	// DialContext specifies the method to dial a connection to the server.
	// DialContext MUST NOT be nil.
	DialContext func(ctx context.Context) (quic.Connection, error)

	// DialTimeout specifies the timeout for DialFunc.
	// Default is defaultDialTimeout.
	DialTimeout time.Duration
	Logger      *zerolog.Logger
}

type ReuseConnOpts

type ReuseConnOpts struct {
	// DialContext specifies the method to dial a connection to the server.
	// DialContext MUST NOT be nil.
	DialContext func(ctx context.Context) (net.Conn, error)

	// DialTimeout specifies the timeout for DialFunc.
	// Default is defaultDialTimeout.
	DialTimeout time.Duration

	// Default is defaultIdleTimeout
	IdleTimeout time.Duration

	Logger *zerolog.Logger
}

type ReuseConnTransport

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

ReuseConnTransport is for old tcp protocol. (no pipelining)

func NewReuseConnTransport

func NewReuseConnTransport(opts ReuseConnOpts) *ReuseConnTransport

func (*ReuseConnTransport) Close

func (t *ReuseConnTransport) Close() error

Close closes ReuseConnTransport and all its connections. It always returns a nil error.

func (*ReuseConnTransport) ExchangeContext

func (t *ReuseConnTransport) ExchangeContext(ctx context.Context, m []byte) (*dnsmsg.Msg, error)

Note: context is not impl while waiting resp. The timeout is hardcoded, which is reuseConnQueryTimeout.

type Transport

type Transport interface {
	// ExchangeContext exchanges query message m to the upstream, and returns
	// response. It MUST NOT keep or modify m.
	// It is the caller's responsibility to release the resp.
	ExchangeContext(ctx context.Context, m []byte) (resp *dnsmsg.Msg, err error)

	io.Closer
}

Jump to

Keyboard shortcuts

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