To reproduce:
ssh has built-in SOCKS server functionality with -D:
Test the SOCKS server:
$ curl --socks5 localhost:1080 https://eth0.me
If the proxy is working, this prints hostname's public IP address.
Java:
static void test() throws Exception {
Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("localhost", 1080));
URLConnection urlConnection = URI.create("https://eth0.me").toURL().openConnection(proxy);
System.out.println(new String(urlConnection.getInputStream().readAllBytes()));
Connection jsoupConnection = Jsoup.connect("https://eth0.me").proxy(proxy);
System.out.println(jsoupConnection.get().text());
System.setProperty("jsoup.useHttpClient", "false");
Connection jsoupConnection2 = Jsoup.connect("https://eth0.me").proxy(proxy);
System.out.println(jsoupConnection2.get().text());
}
This prints hostname's public IP address, then yours, then hostname's again.
HttpClient's lack of support for SOCKS proxies is apparently poorly documented intended behavior (see https://stackoverflow.com/a/70011047 and https://bugs.openjdk.org/browse/JDK-8214516).
I think this can be fixed easily by adding a line to RequestDispatch#get(...):
if (request.proxy() != null && request.proxy().type() != Proxy.Type.HTTP) useHttpClient = false;
In the meantime, affected users (perhaps only me!) can use System.setProperty("jsoup.useHttpClient", "false"); as in my example as a workaround.
To reproduce:
sshhas built-in SOCKS server functionality with-D:Test the SOCKS server:
If the proxy is working, this prints
hostname's public IP address.Java:
This prints
hostname's public IP address, then yours, thenhostname's again.HttpClient's lack of support for SOCKS proxies is apparently poorly documented intended behavior (see https://stackoverflow.com/a/70011047 and https://bugs.openjdk.org/browse/JDK-8214516).I think this can be fixed easily by adding a line to RequestDispatch#get(...):
In the meantime, affected users (perhaps only me!) can use
System.setProperty("jsoup.useHttpClient", "false");as in my example as a workaround.