Documentation
¶
Overview ¶
Package tunnel provides outbound SOCKS5 connection pooling for agbero backends.
A Pool wraps one or more SOCKS5 proxy servers and selects among them using either round-robin (default) or random strategy. It exposes a DialContext function compatible with http.Transport and net.Dialer, making it trivial to inject into any outbound connection path.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Name is optional — used in error messages for named tunnel blocks.
Name string
// Servers is a list of host:port SOCKS5 proxy addresses.
Servers []string
// Username and Password are optional SOCKS5 credentials.
// When empty, the proxy is used without authentication.
Username string
Password string
// Strategy controls server selection: "round_robin" (default) or "random".
Strategy string
}
Config holds the parameters required to construct a Pool.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is a thread-safe SOCKS5 proxy pool. All methods are safe for concurrent use by multiple goroutines.
func New ¶
New constructs a Pool from the given config. Returns an error if any server address is invalid or if the SOCKS5 dialer cannot be initialised.
func NewFromURL ¶
NewFromURL builds a single-server Pool from a socks5://[user:pass@]host:port URI. Used for the inline `tunnel = "socks5://..."` backend shorthand.
func (*Pool) DialContext ¶
DialContext implements the DialContext signature expected by http.Transport. It picks a server per the configured strategy and dials through it.
func (*Pool) WrapTransport ¶
WrapTransport clones t and returns a new *http.Transport whose DialContext routes every outbound TCP connection through this pool.
The cloned transport has Proxy set to nil — SOCKS5 is the proxy. All other transport settings (TLS config, timeouts, connection pooling) are preserved from the original.