gpt4 book ai didi

firefox - 如何发现 pac 中使用的 de proxy

转载 作者:行者123 更新时间:2023-12-04 08:54:51 24 4
gpt4 key购买 nike

在 FireFox 中,互联网连接是通过代理自动配置文件“something.pac”建立的

我如何知道某个 URL 正在使用哪个代理服务器?

谢谢。

最佳答案

.pac 文件只是一个 ECMAscript - 也就是 JavaScript。退房 the wikipedia article关于文件格式。

如果您复制 PAC 代码,您可以对其进行处理,以根据目标 url 查看正在使用的代理。如果你觉得很花哨,你可以把脚本包装成一个网页(本地)来创建一个本地评估的工具。

编辑:

作为我开始推荐的方法的替代方法,您可以查看 PACTester ,在谷歌代码上可用。这将使您能够快速测试一系列选项。

如果您有 .Net 并且有兴趣使用 C#,那么您可以查看 this article on MSDN它具有您可以以与上述类似的方式使用的代码。

为了扩展上面概述的原始方法,主机浏览器可以(并且通常是)提供许多功能。必须在 pac 中实现的基本功能文件是 FindProxyForUrl() .这接受两个参数:url 和主机(从 url 名称派生的主机)。 “提供”的功能包括:isInNet() , localHostOrDomainIs() , isPlainHostName() , isResolvable() , 等等。

如果您在 Microsoft 环境中工作,那么您可以查看 this page on Technet它用一些有用的例子描述了 .pac 格式。

根据 isInNet() 的 Microsoft 文档:

The isInNet(host, pattern, mask) function returns TRUE if the host IP address matches the specified pattern. The mask indicates which part of the IP address to match (255=match, 0=ignore).



如果你想获得技术,这里是 the Mozilla source code用于实现代理自动配置相关服务。它指定了 isInNet() 的 JS 代码作为:
200 function isInNet(ipaddr, pattern, maskstr) {
201 var test = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/(ipaddr);
202 if (test == null) {
203 ipaddr = dnsResolve(ipaddr);
204 if (ipaddr == null)
205 return false;
206 } else if (test[1] > 255 || test[2] > 255 ||
207 test[3] > 255 || test[4] > 255) {
208 return false; // not an IP address
209 }
210 var host = convert_addr(ipaddr);
211 var pat = convert_addr(pattern);
212 var mask = convert_addr(maskstr);
213 return ((host & mask) == (pat & mask));
214
215 }

希望有帮助!

关于firefox - 如何发现 pac 中使用的 de proxy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3068728/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com