Skip to content

Add Built-in Health Check Support#89

Open
v-kamerdinerov wants to merge 4 commits intoserjs:masterfrom
v-kamerdinerov:master
Open

Add Built-in Health Check Support#89
v-kamerdinerov wants to merge 4 commits intoserjs:masterfrom
v-kamerdinerov:master

Conversation

@v-kamerdinerov
Copy link

@v-kamerdinerov v-kamerdinerov commented Feb 13, 2026

Adds native health check functionality to the SOCKS5 proxy server, enabling seamless integration with Docker health checks and monitoring systems.

Changes

Added

  • --healthcheck flag - Built-in health check command that can be invoked directly from the binary
  • Full SOCKS5 protocol handshake - Performs proper SOCKS5 greeting and authentication
  • Automatic authentication detection - Supports both authenticated and non-authenticated modes
  • Docker Compose integration - Ready-to-use health check configuration

Technical Implementation

  • Health check connects to the SOCKS5 port and performs protocol handshake
  • Offers both no-auth (0x00) and username/password (0x02) authentication methods
  • Automatically authenticates using PROXY_USER and PROXY_PASSWORD environment variables when required
  • Returns exit code 0 (success) or 1 (failure) for easy integration with monitoring tools

Benefits

  • ✅ No additional HTTP endpoint or port required
  • ✅ No spurious errors in server logs during health checks
  • ✅ Works with both REQUIRE_AUTH=true and REQUIRE_AUTH=false
  • ✅ Simple Docker health check: test: ["/app/socks5", "--healthcheck"]
  • ✅ Native Go implementation with no external dependencies

Usage

Standalone:

./socks5 --healthcheck

Docker Compose:

healthcheck:
  test: ["/app/socks5", "--healthcheck"]
  interval: 30s
  timeout: 3s
  retries: 3
  start_period: 10s

Additional Changes

  • Code formatting with gofmt
  • Add docs to README.md(also added forgot info about PROXY_LISTEN_IP)
  • Added CHANGELOG.md entry

@v-kamerdinerov
Copy link
Author

@serjs please check this PR

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.

1 participant