s5server

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Port            string
	ListenIP        string
	RequireAuth     bool
	AllowedDestFqdn string
	AllowedIPs      []string
	ReadTimeout     time.Duration
	WriteTimeout    time.Duration
	MaxConnections  int
	Fail2BanRetries int
	Fail2BanTime    time.Duration
	Logger          *slog.Logger
	Telemetry       *Telemetry // Optional custom telemetry

	// Obfuscation settings
	ObfsEnabled    bool
	ObfsPort       string // Separate port for obfuscated connections
	ObfsPSK        string
	ObfsMaxPadding int
	ObfsMTU        int

	// Multi-account settings
	UsersFile            string        // Path to JSON file with user accounts
	TrafficFlushInterval time.Duration // Interval for flushing traffic counters to disk
}

Config represents the configuration for the SOCKS5 server.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a configuration with sensible defaults.

type Server

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

Server represents a controllable SOCKS5 server instance.

func NewServer

func NewServer(cfg Config) (*Server, error)

NewServer initializes a new SOCKS5 server with the given configuration.

func (*Server) AddUser

func (s *Server) AddUser(username, password string) error

AddUser adds a new user for authentication

func (*Server) ReloadUsers added in v1.4.4

func (s *Server) ReloadUsers() error

ReloadUsers reloads the user store from the configured file. Traffic counters are preserved across reloads.

func (*Server) RemoveUser

func (s *Server) RemoveUser(username string) error

RemoveUser removes a user from authentication

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start begins listening and serving traffic. It blocks until stopped.

func (*Server) Stop

func (s *Server) Stop() error

Stop gracefully stops the proxy server.

func (*Server) UpdateWhitelist

func (s *Server) UpdateWhitelist(ips []string) error

UpdateWhitelist updates allowed IPs on the fly

type Telemetry

type Telemetry struct {
	ActiveConnections metric.Int64UpDownCounter
	TotalConnections  metric.Int64Counter
	AuthFailures      metric.Int64Counter
	BytesIn           metric.Int64Counter
	BytesOut          metric.Int64Counter
}

Telemetry holds OpenTelemetry instruments

func InitTelemetry

func InitTelemetry(meterProvider metric.MeterProvider) (*Telemetry, error)

InitTelemetry initializes standard OpenTelemetry metrics

Jump to

Keyboard shortcuts

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