Java SOCKS proxy

五迷三道 提交于 2020-01-24 09:25:09

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/948535/java-socks-proxy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!