connector

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 9 Imported by: 2 modules, 19 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package connector defines interfaces for connecting to destination addresses from the final proxy node in a chain. It handles the application-level handshake (e.g. SOCKS5 CONNECT, HTTP CONNECT) that reaches the target.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBindUnsupported is returned when a connector does not support
	// the BIND operation (reverse tunnels).
	ErrBindUnsupported = errors.New("bind unsupported")
)

Functions

This section is empty.

Types

type BindOption

type BindOption func(opts *BindOptions)

BindOption is a functional option for configuring BindOptions.

func BacklogBindOption

func BacklogBindOption(backlog int) BindOption

BacklogBindOption sets the accept backlog size.

func MuxBindOption

func MuxBindOption(mux bool) BindOption

MuxBindOption sets whether multiplexing is enabled.

func UDPConnTTLBindOption

func UDPConnTTLBindOption(ttl time.Duration) BindOption

UDPConnTTLBindOption sets the UDP connection TTL.

func UDPDataBufferSizeBindOption

func UDPDataBufferSizeBindOption(size int) BindOption

UDPDataBufferSizeBindOption sets the UDP data buffer size.

func UDPDataQueueSizeBindOption

func UDPDataQueueSizeBindOption(size int) BindOption

UDPDataQueueSizeBindOption sets the UDP data queue size.

type BindOptions

type BindOptions struct {
	// Mux enables connection multiplexing on the bind listener.
	Mux bool
	// Backlog is the accept backlog size.
	Backlog int
	// UDPDataQueueSize is the queue size for UDP data packets.
	UDPDataQueueSize int
	// UDPDataBufferSize is the buffer size for UDP data packets.
	UDPDataBufferSize int
	// UDPConnTTL is the TTL for UDP connections.
	UDPConnTTL time.Duration
}

BindOptions holds the runtime parameters for the Bind operation.

type Binder

type Binder interface {
	Bind(ctx context.Context, conn net.Conn, network, address string, opts ...BindOption) (net.Listener, error)
}

Binder is an optional interface implemented by connectors that support reverse tunnels. In a reverse tunnel, the client binds a port and the proxy node listens for incoming connections from the destination side.

type ConnectOption

type ConnectOption func(opts *ConnectOptions)

ConnectOption is a functional option for configuring ConnectOptions.

func DialerConnectOption added in v0.3.2

func DialerConnectOption(dialer xnet.Dialer) ConnectOption

DialerConnectOption sets the dialer for the connect operation.

type ConnectOptions

type ConnectOptions struct {
	// Dialer is used to establish the underlying connection if needed.
	Dialer xnet.Dialer
}

ConnectOptions holds the runtime parameters for the Connect operation.

type Connector

type Connector interface {
	// Init initializes the connector with metadata.
	Init(metadata.Metadata) error
	// Connect establishes a connection to the target address through the
	// given connection (which is already established to the proxy node).
	Connect(ctx context.Context, conn net.Conn, network, address string, opts ...ConnectOption) (net.Conn, error)
}

Connector is responsible for connecting to the destination address through a proxy node. It performs the application-level negotiation that reaches the final target, such as a SOCKS5 CONNECT request or HTTP CONNECT tunnel.

type Handshaker

type Handshaker interface {
	Handshake(ctx context.Context, conn net.Conn) (net.Conn, error)
}

Handshaker performs an application-level handshake on an established connection. This is distinct from the transport-level Handshaker in the dialer package — connector.Handshaker handles protocol negotiation with the destination (e.g. SOCKS5 greeting), while dialer.Handshaker handles transport setup (e.g. TLS).

type Option

type Option func(opts *Options)

Option is a functional option for configuring Options.

func AuthOption

func AuthOption(auth *url.Userinfo) Option

AuthOption sets the authentication credentials.

func LoggerOption

func LoggerOption(logger logger.Logger) Option

LoggerOption sets the logger.

func TLSConfigOption

func TLSConfigOption(tlsConfig *tls.Config) Option

TLSConfigOption sets the TLS configuration.

type Options

type Options struct {
	// Auth is the authentication credentials for the connector.
	Auth *url.Userinfo
	// TLSConfig is the TLS configuration for the connector.
	TLSConfig *tls.Config
	// Logger is the logger for connector operations.
	Logger logger.Logger
}

Options holds the initialization parameters for a Connector.

Jump to

Keyboard shortcuts

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