简体   繁体   English

如何使用Java设置Firefox代理?

[英]how to set proxy for firefox using java?

I am trying to develop an app which will take ip address as a input and set it as a proxy in clients firefox as a proxy. 我正在尝试开发一个将IP地址作为输入并将其设置为客户端firefox中的代理的应用程序。 The idea here is , I am trying to gain access to squid server through java? 这里的想法是,我正试图通过Java获得对鱿鱼服务器的访问权限? is there any possibility of doing so? 有可能这样做吗? Thanks in advance 提前致谢

You can configure your Java application to use Charles in code or as command line arguments to the java executable. 您可以将Java应用程序配置为在代码中或在java可执行文件的命令行参数中使用Charles。

System.setProperty("http.proxyHost", "127.0.0.1"); System.setProperty(“ http.proxyHost”,“ 127.0.0.1”); System.setProperty("http.proxyPort", "8888"); System.setProperty(“ http.proxyPort”,“ 8888”);

And for HTTPS as well. 对于HTTPS也是如此。 Note that you may also want to configure Java to trust Charles's root certificate in this case (see SSL Proxying). 请注意,在这种情况下,您可能还需要配置Java以信任Charles的根证书(请参阅SSL代理)。

System.setProperty("https.proxyHost", "127.0.0.1"); System.setProperty(“ https.proxyHost”,“ 127.0.0.1”); System.setProperty("https.proxyPort", "8888"); System.setProperty(“ https.proxyPort”,“ 8888”);

proxy settings for Firefox are stored in prefs.js file of user Firefox的代理设置存储在用户的prefs.js文件中

%APPDATA%\\Mozilla\\Firefox\\Profiles\\7a3fd5zw.default\\prefs.js %APPDATA%\\ Mozilla \\ Firefox \\ Profiles \\ 7a3fd5zw.default \\ prefs.js

here 7a3fd5zw is a random string. 这里7a3fd5zw是随机字符串。 There are settings named "network.proxy.http" and "network.proxy.http_port". 有名为“ network.proxy.http”和“ network.proxy.http_port”的设置。

May be, you can try to modify them. 可能是,您可以尝试修改它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM