Java SOCKS 代理

发布于 2024-07-23 07:34:44 字数 256 浏览 1 评论 0原文

ocksProxyHost 属性是否需要 IP 地址?

System.setProperty("socksProxyHost", preferences.getProxyHost() );

像上面一样设置,如果我提供 127.0.0.1,我就会连接到本地主机上的代理。 但如果我提供本地主机,它不会连接它。 我在局域网上没有其他机器可以使用它。 那么有谁知道它是否适用于主机名,或者我是否必须解析主机并传入 IP?

Does the socksProxyHost property require an IP address?

System.setProperty("socksProxyHost", preferences.getProxyHost() );

Setting it like above, if I provide 127.0.0.1, I get connected to the proxy on my localhost. But if I provide localhost, it does not connect it. I have no other machines on the LAN I can use to this. So does anyone know if it works with hosts names or do I have to resolve the host and pass in an IP?

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

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

发布评论

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

评论(1

慵挽 2024-07-30 07:34:44

系统属性只是一张愚蠢的地图。 当值发生变化时,不会通知任何观察者。 通常只读取一次值并将其存储在 private static final 中,而不是每次需要时都查找该值。

可能相关代码是在加载应用程序时初始化的,因此该值已被读取。 快速浏览一下 API 文档,您会发现一种很有前途的方法来调用来更改默认代理: ProxySelector.setDefault

System properties are just a dumb map. There are no observers to be notified when a value changes. It is normal to read a value just once and store it in a private static final, rather than looking the value up every time that it is needed.

Probably the relevant code is initialised whilst loading your application, so the value has already been read. A quick look at the API docs shows a promising method to call to change the default proxy: ProxySelector.setDefault.

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