proxy

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RunAsUser string

RunAsUser overrides the system user for the SOCKS5 service. When non-empty the service runs as this user instead of config.SystemUser. Set this before calling any Setup* function when WARP routing is active.

Functions

func Serve

func Serve(addr string, port int, user, pass string) error

Serve starts the built-in SOCKS5 proxy.

func ServeMulti added in v1.6.0

func ServeMulti(addr string, port int, creds map[string]string) error

ServeMulti starts the built-in SOCKS5 proxy with multiple credentials.

func ServeStunTLS added in v1.6.0

func ServeStunTLS(addr string, port int, sshAddr, certFile, keyFile string) error

ServeStunTLS starts the built-in TLS+WebSocket SSH proxy.

func SetupSOCKS

func SetupSOCKS() error

SetupSOCKS creates the SOCKS5 proxy service (localhost only, no auth).

func SetupSOCKSExternal

func SetupSOCKSExternal(user, password string) error

SetupSOCKSExternal creates the SOCKS5 proxy on all interfaces (for direct SOCKS5).

func SetupSOCKSExternalWithUsers added in v1.6.0

func SetupSOCKSExternalWithUsers(users []config.UserConfig) error

SetupSOCKSExternalWithUsers creates the SOCKS5 proxy on all interfaces with multiple users.

func SetupSOCKSWithAuth

func SetupSOCKSWithAuth(user, password string) error

SetupSOCKSWithAuth creates the SOCKS5 proxy with a single user (localhost only).

func SetupSOCKSWithUsers added in v1.6.0

func SetupSOCKSWithUsers(users []config.UserConfig) error

SetupSOCKSWithUsers creates the SOCKS5 proxy with multiple users (localhost only).

Types

type Server

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

Server is a SOCKS5 proxy server supporting CONNECT with optional auth. Credentials can be swapped at runtime via SetCredentials — used to propagate user add/remove events without restarting the listener and dropping live client connections.

func NewServer

func NewServer(addr string, user, pass string) *Server

NewServer creates a SOCKS5 server with a single credential pair. For multiple users, use NewServerMulti.

func NewServerMulti added in v1.6.0

func NewServerMulti(addr string, creds map[string]string) *Server

NewServerMulti creates a SOCKS5 server with multiple credential pairs.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the SOCKS5 server (blocking).

func (*Server) SetCredentials added in v1.6.3

func (s *Server) SetCredentials(creds map[string]string)

SetCredentials replaces the server's credential set atomically. Existing connections are unaffected; new connections authenticate against the new set. Pass an empty map to disable auth.

type StunTLSServer added in v1.6.0

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

StunTLSServer accepts TLS connections and forwards traffic to SSH. It auto-detects the client protocol by peeking at the first bytes:

  • "GET " → WebSocket: HTTP upgrade, then relay WS binary frames ↔ TCP
  • "CONNECT" → HTTP CONNECT proxy: tunnel through to SSH backend
  • "SSH-" → Raw SSH over TLS (stunnel-compatible)
  • other → Payload mode: skip non-SSH prefix bytes, then relay to SSH

func NewStunTLSServer added in v1.6.0

func NewStunTLSServer(listenAddr, sshAddr, certFile, keyFile string) *StunTLSServer

NewStunTLSServer creates a TLS+WebSocket SSH proxy.

func (*StunTLSServer) ListenAndServe added in v1.6.0

func (s *StunTLSServer) ListenAndServe() error

ListenAndServe starts the TLS listener (blocking).

Jump to

Keyboard shortcuts

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