Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SOCKS proxy support #1664

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

mrobinet
Copy link

@mrobinet mrobinet commented Dec 19, 2022

This change adds support for SOCKS4 and SOCKS5 proxies. The use case I have is to test Ratpack services as if they are part of a test environment network. SOCKS proxies offer remote DNS resolution capabilities that allow the service to resolve internal hostnames for the target network/environment. I saw that Netty already has support for SOCKS proxies, but Ratpack was not exposing it.

Example usage:

HttpClient.of(spec ->
    spec.proxy(proxySpec ->
        proxySpec.host("localhost").port(7777).type(Proxy.Type.SOCKS5)
    )
);

I explored a few other options here as well. Instead of a SOCKS proxy you can just use local port forwarding, but if there are a lot of different upstreams then it can be quite tedious to forward all the ports and reconfigure the app to use the proper ports for each upstream. The JVM also has socksProxyHost and socksProxyPort flags, but unfortunately there is a bug in the JVM that prevents remote DNS from working properly when using those, so this was the next best approach.


This change is Reviewable

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.

None yet

1 participant