upstream

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDoTNetwork = "tcp-tls"
	DefaultDoTAddr    = "1.1.1.1:853"
	DefaultDoTTimeout = 2 * time.Second
	DefaultDoTPort    = 853
)
View Source
const (
	DefaultDialTimeout = 500 * time.Millisecond

	NetUDP  = "udp"
	NetUDP4 = "udp4"
	NetUDP6 = "udp6"

	NetTCP  = "tcp"
	NetTCP4 = "tcp4"
	NetTCP6 = "tcp6"

	NetTCPTLS = "tcp-tls"
)
View Source
const (
	DefaultPlainNetwork = "udp"
	DefaultPlainAddr    = "1.1.1.1:53"
	DefaultPlainTimeout = 2 * time.Second
	DefaultPlainPort    = 53
)
View Source
const DefaultPoolSize = 128

Variables

View Source
var (
	ErrMalformedRsp = errors.New("malformed response")
)

Functions

func NewDialer

func NewDialer(opts ...DialOption) *net.Dialer

Types

type ConnPool

type ConnPool interface {
	Acquire(ctx context.Context) (PoolConn, error)
	Close()
}

type DialOption

type DialOption interface {
	Option
	// contains filtered or unexported methods
}

func WithDialTimeout

func WithDialTimeout(timeout time.Duration) DialOption

func WithIface

func WithIface(iface string) DialOption

type DialerFn

type DialerFn func(ctx context.Context) (net.Conn, error)

type DoT

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

func NewDoT

func NewDoT(opts ...Option) (*DoT, error)

func (*DoT) Address

func (d *DoT) Address() string

func (*DoT) Close

func (d *DoT) Close() error

func (*DoT) Exchange

func (d *DoT) Exchange(ctx context.Context, req *dns.Msg) (*dns.Msg, error)

type DoTOption

type DoTOption interface {
	Option
	// contains filtered or unexported methods
}

type NetPool

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

func NewNetPool

func NewNetPool(d DialerFn) *NetPool

func (*NetPool) Acquire

func (p *NetPool) Acquire(ctx context.Context) (PoolConn, error)

func (*NetPool) Close

func (p *NetPool) Close()

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithAddr

func WithAddr(addr string, network string) Option

func WithConnPool

func WithConnPool(maxItems int32) Option

func WithTLSConfig

func WithTLSConfig(cfg *tls.Config) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type Plain

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

func NewPlain

func NewPlain(opts ...Option) (*Plain, error)

func (*Plain) Address

func (p *Plain) Address() string

func (*Plain) Close

func (p *Plain) Close() error

func (*Plain) Exchange

func (p *Plain) Exchange(ctx context.Context, req *dns.Msg) (*dns.Msg, error)

type PlainOption

type PlainOption interface {
	Option
	// contains filtered or unexported methods
}

type PoolConn

type PoolConn interface {
	net.Conn
	Destroy()
}

type PuddlePool

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

func NewPuddlePool

func NewPuddlePool(dialer DialerFn, maxSize int32) (*PuddlePool, error)

func (*PuddlePool) Acquire

func (p *PuddlePool) Acquire(ctx context.Context) (PoolConn, error)

func (*PuddlePool) Close

func (p *PuddlePool) Close()

type Upstream

type Upstream interface {
	// Exchange sends req to this upstream and returns the response that has
	// been received or an error if something went wrong.  The implementations
	// must not modify req as well as the caller must not modify it until the
	// method returns.  It shouldn't be called after closing.
	Exchange(ctx context.Context, req *dns.Msg) (rsp *dns.Msg, err error)

	Address() (addr string)
	Close() error
}

Jump to

Keyboard shortcuts

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