upstream

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: GPL-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConnectTimeout = 30 * time.Second
	DefaultIdleTimeout    = 60 * time.Second
	DefaultQueryTimeout   = 15 * time.Second
)
View Source
const (
	DHCPUpstreamType          = "dhcp"
	DHCPDefaultRequestTimeout = 5 * time.Second
	DHCPDefaultCheckInterval  = 10 * time.Minute
)
View Source
const (
	DefaultFallbackDomain   = "www.example.com"
	DefaultFallbackInterval = 10 * time.Minute
)
View Source
const (
	DefaultHTTPSPath      = "/dns-query"
	DefaultHTTPSUserAgent = "cdns"
)
View Source
const (
	DefaultQueryTestDomain    = "www.example.com"
	DefaultQueryTestInterval  = 10 * time.Minute
	DefaultQueryTestTolerance = 3 * time.Millisecond
)
View Source
const DefaultRetry = 3
View Source
const DefaultUDPBufferSize = 4096
View Source
const FallbackUpstreamType = "fallback"
View Source
const HTTPSUpstreamType = "https"
View Source
const HostsUpstreamType = "hosts"
View Source
const ParallelUpstreamType = "parallel"
View Source
const QUICUpstreamType = "quic"
View Source
const QueryTestUpstreamType = "querytest"
View Source
const RandomUpstreamType = "random"
View Source
const TCPUpstreamType = "tcp"
View Source
const TLSUpstreamType = "tls"
View Source
const UDPUpstreamType = "udp"

Variables

This section is empty.

Functions

func Exchange

func Exchange(ctx context.Context, req *dns.Msg, logger log.Logger, exchangeFunc func(ctx context.Context, req *dns.Msg) (*dns.Msg, error)) (resp *dns.Msg, err error)

func NewDHCPUpstream

func NewDHCPUpstream(ctx context.Context, core adapter.Core, logger log.Logger, tag string, options DHCPUpstreamOptions) (adapter.Upstream, error)

func NewFallbackUpstream

func NewFallbackUpstream(ctx context.Context, core adapter.Core, logger log.Logger, tag string, options FallbackUpstreamOptions) (adapter.Upstream, error)

func NewHTTPSUpstream

func NewHTTPSUpstream(ctx context.Context, core adapter.Core, logger log.Logger, tag string, options HTTPSUpstreamOptions) (adapter.Upstream, error)

func NewHostsUpstream

func NewHostsUpstream(ctx context.Context, core adapter.Core, logger log.Logger, tag string, options HostsUpstreamOptions) (adapter.Upstream, error)

func NewParallelUpstream

func NewParallelUpstream(_ context.Context, core adapter.Core, logger log.Logger, tag string, options ParallelUpstreamOptions) (adapter.Upstream, error)

func NewQUICUpstream

func NewQUICUpstream(ctx context.Context, core adapter.Core, logger log.Logger, tag string, options QUICUpstreamOptions) (adapter.Upstream, error)

func NewQueryTestUpstream

func NewQueryTestUpstream(ctx context.Context, core adapter.Core, logger log.Logger, tag string, options QueryTestUpstreamOptions) (adapter.Upstream, error)

func NewRandomUpstream

func NewRandomUpstream(_ context.Context, core adapter.Core, logger log.Logger, tag string, options RandomUpstreamOptions) (adapter.Upstream, error)

func NewTCPUpstream

func NewTCPUpstream(ctx context.Context, core adapter.Core, logger log.Logger, tag string, options TCPUpstreamOptions) (adapter.Upstream, error)

func NewTLSUpstream

func NewTLSUpstream(ctx context.Context, core adapter.Core, logger log.Logger, tag string, options TLSUpstreamOptions) (adapter.Upstream, error)

func NewUDPUpstream

func NewUDPUpstream(ctx context.Context, core adapter.Core, logger log.Logger, tag string, options UDPUpstreamOptions) (adapter.Upstream, error)

func NewUpstream

func NewUpstream(ctx context.Context, core adapter.Core, logger log.Logger, tag string, options Options) (adapter.Upstream, error)

Types

type DHCPUpstream

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

func (*DHCPUpstream) Close

func (u *DHCPUpstream) Close() error

func (*DHCPUpstream) Dependencies

func (u *DHCPUpstream) Dependencies() []string

func (*DHCPUpstream) Exchange

func (u *DHCPUpstream) Exchange(ctx context.Context, req *dns.Msg) (resp *dns.Msg, err error)

func (*DHCPUpstream) Start

func (u *DHCPUpstream) Start() error

func (*DHCPUpstream) StatisticalData

func (u *DHCPUpstream) StatisticalData() map[string]any

func (*DHCPUpstream) Tag

func (u *DHCPUpstream) Tag() string

func (*DHCPUpstream) Type

func (u *DHCPUpstream) Type() string

type DHCPUpstreamOptions

type DHCPUpstreamOptions struct {
	Interface          string         `yaml:"interface"`
	UseIPv6            bool           `yaml:"use-ipv6,omitempty"`
	CheckInterval      utils.Duration `yaml:"check-interval,omitempty"`
	ConnectTimeout     utils.Duration `yaml:"connect-timeout,omitempty"`
	IdleTimeout        utils.Duration `yaml:"idle-timeout,omitempty"`
	EDNS0              bool           `yaml:"edns0,omitempty"`
	DisableFallbackTCP bool           `yaml:"disable-fallback-tcp,omitempty"`
	EnablePipeline     bool           `yaml:"enable-pipeline,omitempty"`
}

type FallbackUpstream

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

func (*FallbackUpstream) Close

func (u *FallbackUpstream) Close() error

func (*FallbackUpstream) Dependencies

func (u *FallbackUpstream) Dependencies() []string

func (*FallbackUpstream) Exchange

func (u *FallbackUpstream) Exchange(ctx context.Context, req *dns.Msg) (resp *dns.Msg, err error)

func (*FallbackUpstream) Start

func (u *FallbackUpstream) Start() error

func (*FallbackUpstream) StatisticalData

func (u *FallbackUpstream) StatisticalData() map[string]any

func (*FallbackUpstream) Tag

func (u *FallbackUpstream) Tag() string

func (*FallbackUpstream) Type

func (u *FallbackUpstream) Type() string

type FallbackUpstreamOptions

type FallbackUpstreamOptions struct {
	MainUpstream     string         `yaml:"main-upstream"`
	FallbackUpstream string         `yaml:"fallback-upstream"`
	TestDomain       string         `yaml:"test-domain,omitempty"`
	TestInterval     utils.Duration `yaml:"test-interval,omitempty"`
}

type GenericUpstream

type GenericUpstream struct {
	adapter.Upstream
	// contains filtered or unexported fields
}

func (*GenericUpstream) Close

func (g *GenericUpstream) Close() error

func (*GenericUpstream) Exchange

func (g *GenericUpstream) Exchange(ctx context.Context, req *dns.Msg) (*dns.Msg, error)

func (*GenericUpstream) Start

func (g *GenericUpstream) Start() error

type HTTPQUICConn

type HTTPQUICConn struct {
	quic.Connection
	// contains filtered or unexported fields
}

func (*HTTPQUICConn) CloseWithError

func (c *HTTPQUICConn) CloseWithError(code quic.ApplicationErrorCode, reason string) error

type HTTPQUICEarlyConn

type HTTPQUICEarlyConn struct {
	quic.EarlyConnection
	// contains filtered or unexported fields
}

func (*HTTPQUICEarlyConn) CloseWithError

func (c *HTTPQUICEarlyConn) CloseWithError(code quic.ApplicationErrorCode, reason string) error

func (*HTTPQUICEarlyConn) NextConnection

func (c *HTTPQUICEarlyConn) NextConnection() quic.Connection

type HTTPSUpstream

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

func (*HTTPSUpstream) Close

func (u *HTTPSUpstream) Close() error

func (*HTTPSUpstream) Dependencies

func (u *HTTPSUpstream) Dependencies() []string

func (*HTTPSUpstream) Exchange

func (u *HTTPSUpstream) Exchange(ctx context.Context, req *dns.Msg) (*dns.Msg, error)

func (*HTTPSUpstream) Start

func (u *HTTPSUpstream) Start() error

func (*HTTPSUpstream) StatisticalData

func (u *HTTPSUpstream) StatisticalData() map[string]any

func (*HTTPSUpstream) Tag

func (u *HTTPSUpstream) Tag() string

func (*HTTPSUpstream) Type

func (u *HTTPSUpstream) Type() string

type HTTPSUpstreamOptions

type HTTPSUpstreamOptions struct {
	Address          string             `yaml:"address"`
	ConnectTimeout   utils.Duration     `yaml:"connect-timeout,omitempty"`
	IdleTimeout      utils.Duration     `yaml:"idle-timeout,omitempty"`
	TLSOptions       TLSOptions         `yaml:",inline,omitempty"`
	UseHTTP3         bool               `yaml:"use-http3,omitempty"`
	UsePost          bool               `yaml:"use-post,omitempty"`
	Path             string             `yaml:"path,omitempty"`
	Headers          map[string]string  `yaml:"headers,omitempty"`
	BootstrapOptions *bootstrap.Options `yaml:"bootstrap,omitempty"`
	DialerOptions    network.Options    `yaml:",inline,omitempty"`
}

type HTTPTCPConn

type HTTPTCPConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func (*HTTPTCPConn) Close

func (c *HTTPTCPConn) Close() error

type HostsUpstream

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

func (*HostsUpstream) Dependencies

func (u *HostsUpstream) Dependencies() []string

func (*HostsUpstream) Exchange

func (u *HostsUpstream) Exchange(ctx context.Context, req *dns.Msg) (resp *dns.Msg, err error)

func (*HostsUpstream) Start

func (u *HostsUpstream) Start() error

func (*HostsUpstream) StatisticalData

func (u *HostsUpstream) StatisticalData() map[string]any

func (*HostsUpstream) Tag

func (u *HostsUpstream) Tag() string

func (*HostsUpstream) Type

func (u *HostsUpstream) Type() string

type HostsUpstreamOptions

type HostsUpstreamOptions struct {
	Rule     map[string]utils.Listable[string] `yaml:"rule"`
	Fallback string                            `yaml:"fallback"`
}

type Options

type Options struct {
	Tag          string
	Type         string
	QueryTimeout time.Duration

	UDPOptions   *UDPUpstreamOptions
	TCPOptions   *TCPUpstreamOptions
	TLSOptions   *TLSUpstreamOptions
	HTTPSOptions *HTTPSUpstreamOptions
	QUICOptions  *QUICUpstreamOptions

	HostsOptions *HostsUpstreamOptions
	DHCPOptions  *DHCPUpstreamOptions

	RandomOptions    *RandomUpstreamOptions
	ParallelOptions  *ParallelUpstreamOptions
	QueryTestOptions *QueryTestUpstreamOptions
	FallbackOptions  *FallbackUpstreamOptions
}

func (*Options) UnmarshalYAML

func (o *Options) UnmarshalYAML(unmarshal func(interface{}) error) error

type ParallelUpstream

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

func (*ParallelUpstream) Dependencies

func (u *ParallelUpstream) Dependencies() []string

func (*ParallelUpstream) Exchange

func (u *ParallelUpstream) Exchange(ctx context.Context, req *dns.Msg) (resp *dns.Msg, err error)

func (*ParallelUpstream) Start

func (u *ParallelUpstream) Start() error

func (*ParallelUpstream) StatisticalData

func (u *ParallelUpstream) StatisticalData() map[string]any

func (*ParallelUpstream) Tag

func (u *ParallelUpstream) Tag() string

func (*ParallelUpstream) Type

func (u *ParallelUpstream) Type() string

type ParallelUpstreamOptions

type ParallelUpstreamOptions struct {
	Upstreams []string `yaml:"upstreams"`
}

type QUICUpstream

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

func (*QUICUpstream) Close

func (u *QUICUpstream) Close() error

func (*QUICUpstream) Dependencies

func (u *QUICUpstream) Dependencies() []string

func (*QUICUpstream) Exchange

func (u *QUICUpstream) Exchange(ctx context.Context, req *dns.Msg) (*dns.Msg, error)

func (*QUICUpstream) Start

func (u *QUICUpstream) Start() error

func (*QUICUpstream) StatisticalData

func (u *QUICUpstream) StatisticalData() map[string]any

func (*QUICUpstream) Tag

func (u *QUICUpstream) Tag() string

func (*QUICUpstream) Type

func (u *QUICUpstream) Type() string

type QUICUpstreamOptions

type QUICUpstreamOptions struct {
	Address          string             `yaml:"address"`
	ConnectTimeout   utils.Duration     `yaml:"connect-timeout,omitempty"`
	IdleTimeout      utils.Duration     `yaml:"idle-timeout,omitempty"`
	TLSOptions       TLSOptions         `yaml:",inline,omitempty"`
	BootstrapOptions *bootstrap.Options `yaml:"bootstrap,omitempty"`
	DialerOptions    network.Options    `yaml:",inline,omitempty"`
}

type QueryTestUpstream

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

func (*QueryTestUpstream) Close

func (u *QueryTestUpstream) Close() error

func (*QueryTestUpstream) Dependencies

func (u *QueryTestUpstream) Dependencies() []string

func (*QueryTestUpstream) Exchange

func (u *QueryTestUpstream) Exchange(ctx context.Context, req *dns.Msg) (resp *dns.Msg, err error)

func (*QueryTestUpstream) Start

func (u *QueryTestUpstream) Start() error

func (*QueryTestUpstream) StatisticalData

func (u *QueryTestUpstream) StatisticalData() map[string]any

func (*QueryTestUpstream) Tag

func (u *QueryTestUpstream) Tag() string

func (*QueryTestUpstream) Type

func (u *QueryTestUpstream) Type() string

type QueryTestUpstreamOptions

type QueryTestUpstreamOptions struct {
	Upstreams    []string       `yaml:"upstreams"`
	TestDomain   string         `yaml:"test-domain,omitempty"`
	TestInterval utils.Duration `yaml:"test-interval,omitempty"`
	Tolerance    utils.Duration `yaml:"tolerance,omitempty"`
}

type RandomUpstream

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

func (*RandomUpstream) Dependencies

func (u *RandomUpstream) Dependencies() []string

func (*RandomUpstream) Exchange

func (u *RandomUpstream) Exchange(ctx context.Context, req *dns.Msg) (resp *dns.Msg, err error)

func (*RandomUpstream) Start

func (u *RandomUpstream) Start() error

func (*RandomUpstream) StatisticalData

func (u *RandomUpstream) StatisticalData() map[string]any

func (*RandomUpstream) Tag

func (u *RandomUpstream) Tag() string

func (*RandomUpstream) Type

func (u *RandomUpstream) Type() string

type RandomUpstreamOptions

type RandomUpstreamOptions struct {
	Upstreams []string `yaml:"upstreams"`
}

type TCPUpstream

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

func (*TCPUpstream) Close

func (u *TCPUpstream) Close() error

func (*TCPUpstream) Dependencies

func (u *TCPUpstream) Dependencies() []string

func (*TCPUpstream) Exchange

func (u *TCPUpstream) Exchange(ctx context.Context, req *dns.Msg) (resp *dns.Msg, err error)

func (*TCPUpstream) Start

func (u *TCPUpstream) Start() error

func (*TCPUpstream) StatisticalData

func (u *TCPUpstream) StatisticalData() map[string]any

func (*TCPUpstream) Tag

func (u *TCPUpstream) Tag() string

func (*TCPUpstream) Type

func (u *TCPUpstream) Type() string

type TCPUpstreamOptions

type TCPUpstreamOptions struct {
	Address          string             `yaml:"address"`
	ConnectTimeout   utils.Duration     `yaml:"connect-timeout,omitempty"`
	IdleTimeout      utils.Duration     `yaml:"idle-timeout,omitempty"`
	EnablePipeline   bool               `yaml:"enable-pipeline,omitempty"`
	BootstrapOptions *bootstrap.Options `yaml:"bootstrap,omitempty"`
	DialerOptions    network.Options    `yaml:",inline,omitempty"`
}

type TLSOptions

type TLSOptions struct {
	Servername     string                 `yaml:"servername,omitempty"`
	Insecure       bool                   `yaml:"insecure,omitempty"`
	ServerCAFile   utils.Listable[string] `yaml:"server-ca-file,omitempty"`
	ClientCertFile string                 `yaml:"client-cert-file,omitempty"`
	ClientKeyFile  string                 `yaml:"client-key-file,omitempty"`
}

type TLSUpstream

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

func (*TLSUpstream) Close

func (u *TLSUpstream) Close() error

func (*TLSUpstream) Dependencies

func (u *TLSUpstream) Dependencies() []string

func (*TLSUpstream) Exchange

func (u *TLSUpstream) Exchange(ctx context.Context, req *dns.Msg) (resp *dns.Msg, err error)

func (*TLSUpstream) Start

func (u *TLSUpstream) Start() error

func (*TLSUpstream) StatisticalData

func (u *TLSUpstream) StatisticalData() map[string]any

func (*TLSUpstream) Tag

func (u *TLSUpstream) Tag() string

func (*TLSUpstream) Type

func (u *TLSUpstream) Type() string

type TLSUpstreamOptions

type TLSUpstreamOptions struct {
	Address          string             `yaml:"address"`
	ConnectTimeout   utils.Duration     `yaml:"connect-timeout,omitempty"`
	IdleTimeout      utils.Duration     `yaml:"idle-timeout,omitempty"`
	EnablePipeline   bool               `yaml:"enable-pipeline,omitempty"`
	TLSOptions       TLSOptions         `yaml:",inline,omitempty"`
	BootstrapOptions *bootstrap.Options `yaml:"bootstrap,omitempty"`
	DialerOptions    network.Options    `yaml:",inline,omitempty"`
}

type UDPUpstream

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

func (*UDPUpstream) Close

func (u *UDPUpstream) Close() error

func (*UDPUpstream) Dependencies

func (u *UDPUpstream) Dependencies() []string

func (*UDPUpstream) Exchange

func (u *UDPUpstream) Exchange(ctx context.Context, req *dns.Msg) (resp *dns.Msg, err error)

func (*UDPUpstream) Start

func (u *UDPUpstream) Start() error

func (*UDPUpstream) StatisticalData

func (u *UDPUpstream) StatisticalData() map[string]any

func (*UDPUpstream) Tag

func (u *UDPUpstream) Tag() string

func (*UDPUpstream) Type

func (u *UDPUpstream) Type() string

type UDPUpstreamOptions

type UDPUpstreamOptions struct {
	Address            string             `yaml:"address"`
	ConnectTimeout     utils.Duration     `yaml:"connect-timeout,omitempty"`
	IdleTimeout        utils.Duration     `yaml:"idle-timeout,omitempty"`
	EDNS0              bool               `yaml:"edns0,omitempty"`
	DisableFallbackTCP bool               `yaml:"disable-fallback-tcp,omitempty"`
	EnablePipeline     bool               `yaml:"enable-pipeline,omitempty"`
	BootstrapOptions   *bootstrap.Options `yaml:"bootstrap,omitempty"`
	DialerOptions      network.Options    `yaml:",inline,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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