Asyncio-based SOCKS5 server that tunnels connections through configurable chains of SOCKS5, SOCKS4/4a, and HTTP CONNECT proxies. Tor integration via standard SOCKS5 hop.
1.9 KiB
1.9 KiB
s5p
SOCKS5 proxy server with Tor and proxy-chain support. Routes connections through configurable chains of SOCKS4, SOCKS5, and HTTP CONNECT proxies.
Features
- SOCKS5 server (RFC 1928)
- Proxy chaining: tunnel through multiple hops in sequence
- Supported hop protocols: SOCKS5, SOCKS4/4a, HTTP CONNECT
- Per-hop authentication (username/password)
- DNS leak prevention (domain names forwarded to proxies, never resolved locally)
- Tor integration (Tor is just another SOCKS5 hop)
- Pure Python, asyncio-based, minimal dependencies
Quick Start
# Install
cd ~/git/s5p
python -m venv .venv && source .venv/bin/activate
pip install -e .
# Run with Tor
s5p -C socks5://127.0.0.1:9050
# Run with a chain: Tor -> external proxy
s5p -C socks5://127.0.0.1:9050,socks5://proxy:1080
# Run with config file
s5p -c config/example.yaml
# Test it
curl --proxy socks5h://127.0.0.1:1080 https://check.torproject.org/api/ip
Configuration
listen: 127.0.0.1:1080
timeout: 10
chain:
- socks5://127.0.0.1:9050 # Tor
- socks5://user:pass@proxy:1080 # exit-side proxy
- http://proxy2:8080 # HTTP CONNECT proxy
CLI Reference
s5p [-c FILE] [-l [HOST:]PORT] [-C URL[,URL,...]] [-t SEC] [-v|-q]
Options:
-c, --config FILE YAML config file
-l, --listen [HOST:]PORT Listen address (default: 127.0.0.1:1080)
-C, --chain URL[,URL] Comma-separated proxy chain
-t, --timeout SEC Per-hop timeout (default: 10)
-v, --verbose Debug logging
-q, --quiet Errors only
-V, --version Show version
How Chaining Works
Client -> s5p -> Hop1 -> Hop2 -> ... -> HopN -> Destination
s5p connects to Hop1 via TCP, negotiates the hop protocol (SOCKS5/4/HTTP), then over that tunnel negotiates with Hop2, and so on. The final hop connects to the actual destination. Each hop only sees its immediate neighbors.