Skip to content

Add fail2ban-friendly auth failure logging and regression test#91

Open
rezdm wants to merge 1 commit intoserjs:masterfrom
rezdm:feat/fail2ban-auth-logging
Open

Add fail2ban-friendly auth failure logging and regression test#91
rezdm wants to merge 1 commit intoserjs:masterfrom
rezdm:feat/fail2ban-auth-logging

Conversation

@rezdm
Copy link

@rezdm rezdm commented Feb 25, 2026

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-socks5 auth flow (method, username, reason, remote_ip, remote_addr).
  • Added a dedicated warning log line in ServeConn for auth failures:
    • auth_failed remote_ip=... remote_addr=... username=... method=... reason=...
  • Added regression test TestAuthFailureLogsIncludeFail2banFields that 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, and reason=invalid_credentials in logs
  • Updated Changelog.md under Unreleased.

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 ./...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: fail2ban-friendly auth failure logs for failed login attempts

1 participant