Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultTlsConfig() *tls.Config
- func TLSConfigFilterContext(ctx context.Context, filter TLSConfigFilter) context.Context
- func TLSConfigOf(source any) *tls.Config
- type Addr
- type Client
- type Dialer
- type DialerCloser
- type DialerMultiplexed
- type Duration
- type Listener
- type ListenerContext
- type ListenerMultiplexed
- type NativeDialer
- type PacketConn
- type PacketListener
- type Server
- type SubDialer
- type SubListener
- type TCPClientConfig
- type TCPServerConfig
- type TLSConfigFilter
- type TlsConfig
- type TlsDialer
- type TlsListener
- type UDPClientConfig
- type UDPServerConfig
- type UnixClientConfig
- type UnixServerConfig
- type X509Cert
- type X509CertKeyPair
Constants ¶
View Source
const ( ClientAuthOptNone uint8 = 1 << iota >> 1 ClientAuthOptRequest ClientAuthOptOptional ClientAuthOptVerify )
View Source
const ContextKeyTLSCfgFilter contextKey = "network.tls.cfg_filter"
View Source
const TypeTCP = "tcp"
View Source
const TypeTls = "tls"
View Source
const TypeUDP = "udp"
View Source
const TypeUnix = "unix"
Variables ¶
View Source
var ( ErrUnsupportedProtocol = errors.New("unsupported network") ErrUnsupportedUpstream = errors.New("unsupported upstream") )
View Source
var ClientAuthSchemes = map[uint8]tls.ClientAuthType{ ClientAuthOptRequest: tls.RequireAnyClientCert, ClientAuthOptRequest | ClientAuthOptVerify: tls.RequireAndVerifyClientCert, ClientAuthOptRequest | ClientAuthOptOptional: tls.RequestClientCert, ClientAuthOptRequest | ClientAuthOptOptional | ClientAuthOptVerify: tls.VerifyClientCertIfGiven, ClientAuthOptNone: tls.NoClientCert, }
Functions ¶
func DefaultTlsConfig ¶
func TLSConfigFilterContext ¶
func TLSConfigFilterContext(ctx context.Context, filter TLSConfigFilter) context.Context
func TLSConfigOf ¶
Types ¶
type Client ¶
type Client interface { Type() string Config() any Upstream() Client Dialer(ctx context.Context) (Dialer, error) Resolve(network, address string) (net.Addr, error) }
func NewTCPClient ¶
func NewTCPClient(cfg TCPClientConfig) Client
func NewTLSClient ¶
type Dialer ¶
type Dialer interface { Client() Client Underlying() any NativeDialer }
type DialerCloser ¶
type DialerMultiplexed ¶
type ListenerContext ¶
type ListenerMultiplexed ¶
type NativeDialer ¶
type PacketConn ¶
type PacketConn interface { Underlying() any net.PacketConn }
type PacketListener ¶
type PacketListener interface {
ListenPacket(ctx context.Context) (packetConn PacketConn, err error)
}
type Server ¶
type Server interface { Type() string Addr() Addr Config() any Upstream() Server ListenPacket(ctx context.Context) (packetConn PacketConn, err error) ListenContext(ctx context.Context) (listener Listener, err error) }
func NewTCPServer ¶
func NewTCPServer(cfg TCPServerConfig, addr string) Server
func NewTLSServer ¶
func NewUDPServer ¶
func NewUDPServer(cfg UDPServerConfig, addr string) Server
type SubListener ¶
type TCPClientConfig ¶
type TCPClientConfig struct { EnableNoDelay bool `json:"enable_no_delay" yaml:"enable_no_delay"` KeepAliveInterval Duration `json:"keep_alive_interval" yaml:"keep_alive_interval"` StackFallbackGap Duration `json:"stack_fallback_gap" yaml:"stack_fallback_gap"` TimeoutDuration Duration `json:"dial_timeout" yaml:"dial_timeout"` LocalNetwork string `json:"local_network" yaml:"local_network"` LocalAddress string `json:"local_address" yaml:"local_address"` }
type TCPServerConfig ¶
type TLSConfigFilter ¶
func NewTlsNextProtoFilter ¶
func NewTlsNextProtoFilter(list []string) TLSConfigFilter
type TlsConfig ¶
type TlsConfig struct { Disable bool `json:"disable" yaml:"disable"` WithoutSysCA bool `json:"without_sys_ca" yaml:"without_sys_ca"` SkipVerify bool `json:"insecure_skip_verify" yaml:"insecure_skip_verify"` SkipVerifyHost bool `json:"skip_verify_host" yaml:"skip_verify_host"` ClientAuth struct { Optional bool `json:"optional" yaml:"optional"` Request bool `json:"request" yaml:"request"` Verify bool `json:"verify" yaml:"verify"` } `json:"client_auth" yaml:"client_auth"` ServerName string `json:"server_name" yaml:"server_name"` KeyLogPath string `json:"key_log_path" yaml:"key_log_path"` RootCAs []X509Cert `json:"root_ca_list" yaml:"root_ca_list"` ClientCAs []X509Cert `json:"client_ca_list" yaml:"client_ca_list"` Certs []X509CertKeyPair `json:"cert_list" yaml:"cert_list"` }
type TlsListener ¶
type TlsListener interface { SubListener // contains filtered or unexported methods }
type UDPClientConfig ¶
type UDPServerConfig ¶
type UDPServerConfig struct {
KeepAliveInterval Duration `json:"keep_alive_interval"`
}
type UnixClientConfig ¶
type UnixClientConfig struct { RemoveBeforeServe bool `json:"remove_before_serve"` KeepAliveInterval Duration `json:"keep_alive_interval"` StackFallbackGap Duration `json:"stack_fallback_gap"` TimeoutDuration Duration `json:"dial_timeout"` LocalNetwork string `json:"local_network"` LocalAddress string `json:"local_address"` }
type UnixServerConfig ¶
type X509Cert ¶
func (*X509Cert) BuildX509Certificate ¶
func (c *X509Cert) BuildX509Certificate() (certs []*x509.Certificate, err error)
type X509CertKeyPair ¶
type X509CertKeyPair struct { Cert string `json:"cert"` CertPath string `json:"cert_path"` Key string `json:"key"` KeyPath string `json:"key_path"` }
func (*X509CertKeyPair) BuildTLSCertificate ¶
func (c *X509CertKeyPair) BuildTLSCertificate() (cert tls.Certificate, err error)
Click to show internal directories.
Click to hide internal directories.