一个基于 Go 的轻量 SOCKS5 代理,支持用户密码认证、无认证(受限场景)、CLI/环境变量配置、结构化日志。
go build -o socks5 ././socks5 \
--bind 127.0.0.1 \
--port 1088 \
--users "user1:pass1,user2:pass2" \
--log-level info \
--log-format text参数说明:
--bind: 监听地址,默认127.0.0.1--port: 监听端口,默认1088--users: 用户清单(逗号分隔,形如user:pass)。为空则为无认证模式--log-level:debug|info|warn|error(默认info)--log-format:text|json(默认text)
export SOCKS5_BIND=0.0.0.0
export SOCKS5_PORT=1088
export SOCKS5_USERS="garden:garden"
export SOCKS5_LOG_LEVEL=info
export SOCKS5_LOG_FORMAT=text
./socks5环境变量(覆盖 CLI 同名参数):
SOCKS5_BINDSOCKS5_PORTSOCKS5_USERSSOCKS5_LOG_LEVELSOCKS5_LOG_FORMAT
-
无认证(仅受信网络):
./socks5 --users "" --bind 127.0.0.1 --port 1088 -
多用户认证:
./socks5 --users "alice:alice,bob:bob" -
JSON 日志:
./socks5 --log-format json --log-level debug
- 无认证模式仅适用于受信环境或开发调试,请勿暴露到公网。
- 若需要对外提供服务,建议绑定在受控网段或使用外层防火墙/ACL。
- 经测试可构建在 macOS、Linux、Windows 以及常见的 amd64/arm64 架构。
GOOS=linux GOARCH=arm64 go build -o socks5-linux-arm64 ./