SOCKS5 listener #33

Merged
mikluko merged 1 commit from feat/socks5 into main 2026-10-26 21:07:02 +00:00
Owner

Closes #8.

The new socks5 package serves each SOCKS5 CONNECT as an in-process HTTP CONNECT to an http.Handler. The command hands it the same router as the HTTP listener, so routing is shared rather than reimplemented. The tunnel and MITM handlers accept by hijacking and writing 200 OK; the server answers the client with SOCKS success in place of that line. Refusals map to reply codes: 403/405 to not allowed, 502 to host unreachable, 504 to TTL expired.

Supports CONNECT with no authentication, and IPv4, IPv6 and domain addresses. Tests cover tunnel, MITM, refusal, unreachable hosts and protocol errors, and pass under -race. A smoke run of the binary with curl --socks5-hostname tunnels and is refused as expected.

Closes #8. The new `socks5` package serves each SOCKS5 CONNECT as an in-process HTTP `CONNECT` to an `http.Handler`. The command hands it the same router as the HTTP listener, so routing is shared rather than reimplemented. The tunnel and MITM handlers accept by hijacking and writing `200 OK`; the server answers the client with SOCKS success in place of that line. Refusals map to reply codes: 403/405 to not allowed, 502 to host unreachable, 504 to TTL expired. Supports CONNECT with no authentication, and IPv4, IPv6 and domain addresses. Tests cover tunnel, MITM, refusal, unreachable hosts and protocol errors, and pass under `-race`. A smoke run of the binary with curl `--socks5-hostname` tunnels and is refused as expected.
SOCKS5 listener
All checks were successful
CI / changelog (pull_request) Successful in 6s
CI / test (pull_request) Successful in 39s
e3648acb22
-socks serves SOCKS5 CONNECT as in-process HTTP CONNECT requests to the same
router, so SOCKS clients get the tunnel, MITM and refusal rules of HTTP ones
and cannot sidestep them.

Closes #8
mikluko deleted branch feat/socks5 2026-10-26 21:07:02 +00:00
Sign in to join this conversation.
No description provided.