proxy

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConnKeepalive = 15 * time.Second
	MinConnKeepalive     = 15 * time.Second
	MaxConnKeepalive     = 2 * time.Hour
)
View Source
const (
	DefaultDialTimeout = 3 * time.Minute
	MinDialTimeout     = 10 * time.Millisecond
	MaxDialTimeout     = 5 * time.Minute
)
View Source
const (
	DefaultConnTimeout = 30 * time.Second
	MinConnTimeout     = 0 * time.Second
	MaxConnTimeout     = 2 * time.Hour
)
View Source
const (
	DefaultPKCS11TokenMaxRetries int = 3
	MinPKCS11TokenMaxRetries     int = 1
	MaxPKCS11TokenMaxRetries     int = 50
)
View Source
const (
	DefaultPKCS11TokenRetryInterval = 5 * time.Second
	MinPKCS11TokenRetryInterval     = 1 * time.Second
	MaxPKCS11TokenRetryInterval     = 60 * time.Second
)
View Source
const (
	DefaultPKCS11TokenPollInterval = 2 * time.Second
	MinPKCS11TokenPollInterval     = 1 * time.Second
	MaxPKCS11TokenPollInterval     = 60 * time.Second
)

Variables

This section is empty.

Functions

func NewTCPListener

func NewTCPListener(ctx context.Context, config ProxyClientConfig) (net.Listener, error)

Types

type ClientHandler

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

func NewClientHandler

func NewClientHandler(
	clientConfig ProxyClientConfig,
	serverConfig ProxyServerConfig,
	clientConnCh <-chan net.Conn,
	tlsConfigCh <-chan *tls.Config,
	errCh chan<- error,
) *ClientHandler

func (*ClientHandler) Handle

func (h *ClientHandler) Handle(ctx context.Context)

Handle handles the client side of the proxy.

type ConnKeepalive

type ConnKeepalive time.Duration

func (ConnKeepalive) Validate

func (ka ConnKeepalive) Validate() error

type ConnTimeout

type ConnTimeout struct {
	Read  time.Duration
	Write time.Duration
}

func (ConnTimeout) Validate

func (t ConnTimeout) Validate() error

type DialTimeout

type DialTimeout time.Duration

func (DialTimeout) Validate

func (t DialTimeout) Validate() error

type ListenerHandler

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

func NewListenerHandler

func NewListenerHandler(
	listener net.Listener,
	clientConnCh chan<- net.Conn,
	errCh chan<- error,
) *ListenerHandler

func (*ListenerHandler) Close

func (h *ListenerHandler) Close()

func (*ListenerHandler) Handle

func (h *ListenerHandler) Handle(
	ctx context.Context,
)

Handle handles the client side listener of the proxy for accepting new connections.

func (*ListenerHandler) WatchClose

func (h *ListenerHandler) WatchClose(ctx context.Context)

type PKCS11TokenHandler

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

func NewPKCS11TokenHandler

func NewPKCS11TokenHandler(
	ctxLoader pkcs11.PKCS11CtxLoader,
	certId []byte,
	tlsConfigCh chan<- *tls.Config,
	maxRetries PKCS11TokenMaxRetries,
	retryInterval PKCS11TokenRetryInterval,
	pollInterval PKCS11TokenPollInterval,
	errCh chan<- error,
) *PKCS11TokenHandler

func (*PKCS11TokenHandler) Handle

func (h *PKCS11TokenHandler) Handle(
	ctx context.Context,
)

Handle interfaces with the PKCS#11 token to get the TLS certificate used by the proxy.

type PKCS11TokenMaxRetries

type PKCS11TokenMaxRetries int

func (PKCS11TokenMaxRetries) Validate

func (r PKCS11TokenMaxRetries) Validate() error

type PKCS11TokenPollInterval

type PKCS11TokenPollInterval time.Duration

func (PKCS11TokenPollInterval) Validate

func (i PKCS11TokenPollInterval) Validate() error

type PKCS11TokenRetryInterval

type PKCS11TokenRetryInterval time.Duration

func (PKCS11TokenRetryInterval) Validate

func (i PKCS11TokenRetryInterval) Validate() error

type ProxyClientConfig

type ProxyClientConfig struct {
	Host          string
	Port          int
	ConnKeepalive ConnKeepalive
	ConnTimeout   ConnTimeout
}

type ProxyHandler

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

func NewProxyHandler

func NewProxyHandler(
	errCh chan<- error,
	tokenHandler *PKCS11TokenHandler,
	tokenHandlerErrCh <-chan error,
	listenerHandler *ListenerHandler,
	listenerHandlerErrCh <-chan error,
	clientHandler *ClientHandler,
	clientHandlerErrCh <-chan error,
) *ProxyHandler

func (*ProxyHandler) Close

func (h *ProxyHandler) Close()

func (*ProxyHandler) Handle

func (h *ProxyHandler) Handle(ctx context.Context)

Handle handles the proxy logic.

type ProxyServerConfig

type ProxyServerConfig struct {
	Host          string
	Port          int
	DialTimeout   DialTimeout
	ConnKeepalive ConnKeepalive
	ConnTimeout   ConnTimeout
}

Jump to

Keyboard shortcuts

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