upstream

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Opt

type Opt struct {
	// DialAddr specifies the address the upstream will
	// actually dial to in the network layer by overwriting
	// the address inferred from upstream url.
	// It won't affect high level layers. (e.g. SNI, HTTP HOST header won't be changed).
	// Can be an IP or a domain. Port is optional.
	// Tips: If the upstream url host is a domain, specific an IP address
	// here can skip resolving ip of this domain.
	//
	// Special usage:
	// If DialAddr has a "@" prefix, and the upstream protocol is stream/tcp based (tcp/tls/http/https),
	// then it will dial an abstract unix socket.
	DialAddr string

	// IdleTimeout specifies the timeout for dialing new connection.
	// Default value is about 3~5s (depending on upstream protocol and system settings).
	DialTimeout time.Duration

	// IdleTimeout specifies the idle timeout for long-connections.
	// Default: TCP, DoT: 10s , DoH, DoH3, DoQ: 30s.
	IdleTimeout time.Duration

	// EnablePipeline enables query pipelining support as RFC 7766 6.2.1.1 suggested.
	// Available for TCP, DoT upstream.
	// Note: There is no fallback. Make sure the server supports it.
	EnablePipeline bool

	// EnableHTTP3 will use HTTP/3 protocol to connect a DoH upstream. (aka DoH3).
	// Note: There is no fallback. Make sure the server supports it.
	EnableHTTP3 bool

	// TLSConfig specifies the tls.Config that the TLS client will use.
	// Available for DoT, DoH, DoQ upstream.
	TLSConfig *tls.Config

	// Logger specifies the logger that the upstream will use.
	Logger *zerolog.Logger

	// Set the Control field in net.ListenConfig / net.Dialer when creating
	// upstream connections.
	Control func(network, address string, c syscall.RawConn) error
}

type Upstream

type Upstream = transport.Transport

func NewUpstream

func NewUpstream(addr string, opt Opt) (_ Upstream, err error)

NewUpstream creates a upstream. addr has the format of: [protocol://]host[:port][/path]. Supported protocol: udp/tcp/tls/https/quic. Default protocol is udp.

Helper protocol:

  • tcp+pipeline/tls+pipeline: Automatically set opt.EnablePipeline to true.
  • h3: Automatically set opt.EnableHTTP3 to true.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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