Repository navigation
feat: support SOCKS5 proxies in the HTTP client - #1579
Merged
Merged
Conversation
Collaborator
Author
|
Full module |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
SOCKS-routed requests can leak HTTP proxy credentials to origin servers, and an empty SOCKS host incorrectly routes traffic to a loopback proxy instead of connecting directly.
2 open issues
What changed in this PR
Adds SOCKS5 proxy support to the Netty HTTP client for environments such as SSH dynamic forwarding, while preserving HTTP proxy precedence.
Changes:
- Adds SOCKS configuration parameters, system-property fallbacks, authentication, and proxy-side hostname resolution.
- Applies proxy bypass rules to SOCKS and avoids HTTP/3 on SOCKS routes.
- Adds integration tests and a changelog entry.
| File | Description |
|---|---|
org.restlet/src/test/java/org/restlet/engine/connector/SocksProxyTestCase.java |
Adds a test SOCKS5 proxy and coverage for routing, authentication, reuse, bypass, and system properties. |
org.restlet/src/main/java/org/restlet/engine/netty/NettyClientHelper.java |
Implements SOCKS5 configuration and connection handling for HTTP and HTTPS. |
changes.md |
Documents SOCKS5 support and configuration options. |
Review effort: Balanced
jlouvel
force-pushed
the
feat/netty-socks-proxy
branch
from
October 31, 2026 07:44
1b3068f to
8a20e06
Compare
jlouvel
force-pushed
the
feat/netty-socks-proxy
branch
from
November 1, 2026 14:56
8a20e06 to
b9f1a5b
Compare
jlouvel
force-pushed
the
feat/netty-socks-proxy
branch
from
November 1, 2026 16:18
b9f1a5b to
d27f926
Compare
Base automatically changed from
fix/netty-http2-forward-proxy
to
fix/netty-non-proxy-hosts
November 1, 2026 20:09
jlouvel
force-pushed
the
feat/netty-socks-proxy
branch
2 times, most recently
from
November 1, 2026 21:24
200f1b0 to
1711d9c
Compare
The Netty client only supported HTTP proxies, while some environments only provide a SOCKS proxy, such as SSH dynamic port forwarding. - NettyClientHelper: new "socksProxyHost", "socksProxyPort", "socksProxyUsername" and "socksProxyPassword" parameters, defaulting to the JDK system properties. Requests without HTTP proxy connect through Netty's Socks5ProxyHandler, for both HTTP and HTTPS, with origin-form request targets; the proxy resolves the host names. The nonProxyHosts list applies, and HTTP/3 is not used through the SOCKS proxy. - SocksProxyTestCase: minimal SOCKS5 test proxy, HTTP and HTTPS requests, username/password authentication, refused credentials, bypass and system properties. Closes #1573. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jerome Louvel <374450+jlouvel@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… hosts - NettyClientCall: the removal of the Proxy-Authorization header of the requests that neither go through a CONNECT tunnel nor to a forward proxy also covers the requests connected through a SOCKS proxy, so the HTTP proxy credentials don't reach the origin server. Document it. - NettyClientHelper: an empty SOCKS proxy host means no SOCKS proxy, instead of a SOCKS proxy on the loopback address. - SocksProxyTestCase: no proxy credentials received by HTTP and HTTPS origins reached through SOCKS, direct connection for an empty host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jlouvel
force-pushed
the
feat/netty-socks-proxy
branch
from
November 1, 2026 21:24
1711d9c to
eaefba7
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





Closes #1573. Based on #1578.
The Netty client only supported HTTP proxies. Some environments only provide a SOCKS proxy, such as SSH dynamic port forwarding (
ssh -D) or some corporate networks.Changes
NettyClientHelper:New connector parameters, each falling back to the JDK system property of the same purpose:
socksProxyHostsocksProxyHostsocksProxyPortsocksProxyPortsocksProxyUsernamejava.net.socks.usernamesocksProxyPasswordjava.net.socks.passwordRequests without an HTTP proxy for their scheme go through Netty's
Socks5ProxyHandler, for both HTTP and HTTPS. The HTTP proxy takes precedence. Requests use origin-form targets, and the proxy resolves the host names (likesocks5h).nonProxyHostsapplies to the SOCKS proxy too, and HTTP/3 is not used through it, since QUIC would need UDP ASSOCIATE.initConnection()now builds either aSocks5ProxyHandleror anHttpProxyHandler, and shares the setup from fix: send proxy credentials with the CONNECT request of HTTPS tunnels #1574: protocol handlers are added only once the proxy connection is established, and proxy failures are reported through the ready promise.New public getters and Javadoc rows for the parameters.
SocksProxyTestCase: a minimal SOCKS5 test proxy (RFC 1928 / RFC 1929). Tests cover HTTP with connection reuse, HTTPS with username/password, refused credentials (connector error),nonProxyHostsbypass, and the system properties.changes.md: entry under Enhancements.netty-handler-proxyis already a dependency, and it bringsnetty-codec-socks, so no new library is needed. Only SOCKS5 is supported, not SOCKS4/4a.Behavior change (accepted)
A JVM with the
socksProxyHostsystem property set now sends the requests of the Restlet client through that SOCKS proxy, asjava.net.Socketalready does. Before, the Netty client ignored the property. As with the HTTP proxy, the loopback addresses bypass it unlessnonProxyHostssays otherwise (see #1577).Validation
ProxyTestCase(11 tests) andSocksProxyTestCase(5 tests) pass.🤖 Generated with Claude Code