socks5-server
socks5-server copied to clipboard
Add fail2ban-friendly auth failure logging and regression test
Closes #90
Summary
This PR improves authentication failure observability and fail2ban integration by adding a stable, parseable auth failure log line with source IP details.
What Changed
- Added structured auth failure metadata in vendored
go-socks5auth flow (method,username,reason,remote_ip,remote_addr). - Added a dedicated warning log line in
ServeConnfor auth failures:auth_failed remote_ip=... remote_addr=... username=... method=... reason=...
- Added regression test
TestAuthFailureLogsIncludeFail2banFieldsthat performs a real SOCKS5 username/password handshake with invalid credentials and validates:- auth response failure (
0x01 0x01) - presence of
auth_failed,remote_ip,username,method, andreason=invalid_credentialsin logs
- auth response failure (
- Updated
Changelog.mdunderUnreleased.
Example Log
[WARN] socks: auth_failed remote_ip=127.0.0.1 remote_addr="127.0.0.1:47966" username="testuser" method=2 reason=invalid_credentials
Validation
GOCACHE=/tmp/go-build-cache go test ./...GOCACHE=/tmp/go-build-cache go vet ./...