Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // SOCKS proxy connection metrics. SocksConnectionRequests = prometheus.NewCounter( prometheus.CounterOpts{ Name: "socks_connection_requests_total", Help: "Total number of connection requests to the SOCKS proxy server.", }, ) SocksConnectionsActive = prometheus.NewGauge( prometheus.GaugeOpts{ Name: "socks_connections_active", Help: "Number of currently active SOCKS connections.", }, ) SocksConnectionFailures = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "socks_connection_failures_total", Help: "Total number of failed SOCKS connection attempts.", }, []string{"reason"}, ) SocksConnectionDuration = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Name: "socks_connection_duration_seconds", Help: "Duration of SOCKS connections in seconds.", Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), }, []string{"destination_type"}, ) // SOCKS proxy data transfer metrics. SocksBytesTransferred = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "socks_bytes_transferred_total", Help: "Total number of bytes transferred through the SOCKS proxy.", }, []string{"direction", "destination_type"}, ) // SOCKS proxy DNS metrics. SocksDNSRequests = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "socks_dns_requests_total", Help: "Total number of DNS requests made by the SOCKS proxy.", }, []string{"result"}, ) SocksDNSLatency = prometheus.NewHistogram( prometheus.HistogramOpts{ Name: "socks_dns_latency_seconds", Help: "Latency of DNS resolution in seconds.", Buckets: prometheus.ExponentialBuckets(0.001, 2, 10), }, ) // SOCKS proxy authentication metrics. SocksAuthAttempts = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "socks_auth_attempts_total", Help: "Total number of authentication attempts.", }, []string{"method", "result"}, ) // SOCKS command metrics. SocksCommands = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "socks_commands_total", Help: "Total number of SOCKS commands received.", }, []string{"command", "result"}, ) // SOCKS proxy error metrics. SocksErrors = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "socks_errors_total", Help: "Total number of SOCKS proxy errors.", }, []string{"error_type"}, ) )
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*config)
Option configures a ProxyServer's connection lifecycle.
func WithIdleTimeout ¶
WithIdleTimeout bounds how long a proxied connection may transfer zero bytes in either direction before it is force-closed. A non-positive value disables the idle backstop (keepalive and any max-lifetime still apply).
func WithKeepAlive ¶
WithKeepAlive toggles TCP keepalive on proxied connections and sets the probe period. A non-positive period leaves the system default period in place.
func WithMaxLifetime ¶
WithMaxLifetime caps the absolute lifetime of a proxied connection measured from when it was accepted/dialed. A non-positive value (the default) disables the cap so long-lived active streams are not interrupted.
type ProxyServer ¶
type ProxyServer struct {
Addr string
// contains filtered or unexported fields
}
ProxyServer is a SOCKS5 proxy server.
func NewServer ¶
func NewServer(addr string, upstream network.Network, fallback network.Network, opts ...Option) *ProxyServer
NewServer creates a new SOCKS5 proxy server. Requests to private addresses (excluding loopback) will be forwarded to the upstream network. Requests to public addresses will be forwarded to the fallback network.
func (*ProxyServer) Close ¶
func (s *ProxyServer) Close() error
func (*ProxyServer) ListenAndServe ¶
func (s *ProxyServer) ListenAndServe(ctx context.Context) error