upstream

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: GPL-3.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FastUpstream

type FastUpstream struct {
	Logger *zap.Logger // Nil value disables the logger.

	// Addr is a network "host:port" addr
	Addr       string
	Protocol   Protocol // Default is ProtocolUDP.
	Socks5     string   // Used by "tcp", "dot", "doh" as Socks5 server addr.
	ServerName string   // Used by "dot" as server certificate name. It cannot be empty.
	URL        string   // Used by "doh" as server endpoint url. It cannot be empty.

	// ReadTimeout
	// In "udp", "tcp", "dot", it's read timeout.
	// In "doh", it's a time limit for the query, including dialing connections.
	// Default is generalReadTimeout.
	ReadTimeout time.Duration

	// IdleTimeout used by "tcp", "dot", "doh" to control connection idle timeout.
	// Default: "tcp" & "dot": 0 (disable connection reuse), "doh": 30s.
	IdleTimeout time.Duration

	// MaxConns limits the total number of connections,
	// including connections in the dialing states.
	// Used by "udp"(fallback to tcp), "tcp", "dot", "doh". Default: 1.
	MaxConns int

	RootCA             *x509.CertPool
	InsecureSkipVerify bool // Used by "dot", "doh". Skip tls verification.
	// contains filtered or unexported fields
}

FastUpstream is a udp, tcp, dot, doh upstream

func (*FastUpstream) Exchange

func (u *FastUpstream) Exchange(q *dns.Msg) (r *dns.Msg, err error)

func (*FastUpstream) ExchangeNoTruncated added in v1.5.2

func (u *FastUpstream) ExchangeNoTruncated(q *dns.Msg) (r *dns.Msg, err error)

type Protocol

type Protocol uint8
const (
	ProtocolUDP Protocol = iota
	ProtocolTCP
	ProtocolDoT
	ProtocolDoH
)

DNS protocols

type Transport added in v1.5.2

type Transport struct {
	// Nil logger disables logging.
	Logger *zap.Logger

	// The following funcs cannot be nil.
	DialFunc  func() (net.Conn, error)
	WriteFunc func(c io.Writer, m *dns.Msg) (n int, err error)
	ReadFunc  func(c io.Reader) (m *dns.Msg, n int, err error)
	// MaxConns controls the maximum connections Transport can open.
	// It includes dialing connections.
	// Default is 1.
	MaxConns int

	// IdleTimeout controls the maximum idle time for each connection.
	// If IdleTimeout <= 0, Transport will not reuse connections.
	IdleTimeout time.Duration

	// Timeout controls the read timeout for each read operation.
	// Default is defaultReadTimeout.
	Timeout time.Duration
	// contains filtered or unexported fields
}

func (*Transport) Exchange added in v1.5.2

func (t *Transport) Exchange(q *dns.Msg) (r *dns.Msg, err error)

Jump to

Keyboard shortcuts

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