为什么Java不支持socks4?

发布于 2024-08-23 07:29:38 字数 836 浏览 3 评论 0原文

考虑此代码:

    Proxy p = new Proxy(Type.SOCKS, new InetSocketAddress(proxyURL, port));
    try {

        long time = System.currentTimeMillis();
        URLConnection urlConn = url.openConnection(p);
        System.out.println(urlConn.getContent());
        int ping = (int)(System.currentTimeMillis() - time);
        System.out.println(proxyURL+ ":" +port+ " ... works as SOCKS, ping: " +ping);           
    } catch (IOException e) {
        //e.printStackTrace();
    }

我已经通过 Wireshark 验证这在有效的ocks4代理上不起作用。此时,这些是有效的socks4 ONLY代理服务器:

92.241.233.75:1080
58.214.5.162:1080
222.51.38.138:1080
121.8.124.42:1080
220.179.61.62:1080
75.125.63.178:1080
201.59.145.141:1080
117.20.60.144:1080

但是,给它提供一个有效的socks5代理,它就可以正常工作:

    62.243.224.179

Take this code into consideration:

    Proxy p = new Proxy(Type.SOCKS, new InetSocketAddress(proxyURL, port));
    try {

        long time = System.currentTimeMillis();
        URLConnection urlConn = url.openConnection(p);
        System.out.println(urlConn.getContent());
        int ping = (int)(System.currentTimeMillis() - time);
        System.out.println(proxyURL+ ":" +port+ " ... works as SOCKS, ping: " +ping);           
    } catch (IOException e) {
        //e.printStackTrace();
    }

I have verified though Wireshark that this doesn't work on a valid socks4 proxy. At this time these are valid socks4 ONLY proxy servers:

92.241.233.75:1080
58.214.5.162:1080
222.51.38.138:1080
121.8.124.42:1080
220.179.61.62:1080
75.125.63.178:1080
201.59.145.141:1080
117.20.60.144:1080

Yet, feed it a valid socks5 proxy and it works fine:

    62.243.224.179

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

亢潮 2024-08-30 07:29:38

这是一个答案。我没有测试它,但听起来它会起作用(但不是理想的解决方案)。

Here is an answer. I didn't test it, but sounds like it'll work (but not an ideal solution).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文