如何发现在pac中使用de代理 [英] How to discover de proxy used in a pac

查看:137
本文介绍了如何发现在pac中使用de代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在FireFox中,通过代理自动配置文件something.pac进行互联网连接。



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



谢谢。

解决方案

.pac文件只是一个emca脚本 - 又名JavaScript。查看维基百科文章的文件格式。



如果复制PAC代码,则可以根据目标url来处理它以查看正在使用的代理。如果你觉得奇特,你可以把脚本包装到一个网页(本地)来创建一个工具来评估本地。

编辑:



作为我开始推荐的方法的替代方法,您可以查看 PACTester ,可在Google Code上找到。这将允许你快速测试一系列的选项。

如果你有.Net可用,并有兴趣玩C#,那么你可以检查出 MSDN上的这篇文章,其中的代码可以用类似于上面的方式使用。 p>

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



如果您在Microsoft环境那么您可以查看 Technet上的此页面,其中描述了.pac格式以下是一些有用的例子。



对于的微软文档isInNet()


isInNet(host,pattern,mask)函数返回 TRUE 如果主机IP地址匹配指定的模式掩码指示匹配IP地址的哪一部分(255 =匹配,0 =忽略)。

如果您想获得技术支持,请点击 Mozilla源代码来实现代理自动配置相关的服务。它为 isInNet()指定了JS代码:

  200函数(\ d {1,3})\。(\ d { 1,3})\(\d {1,3})$ /(IPADDR); 
202 if(test == null){
203 ipaddr = dnsResolve(ipaddr);
204 if(ipaddr == null)
205返回false;
206} else if(test [1]> 255 || test [2]> 255 ||
207 test [3]> 255 || test [4]> 255){
208返回false; //不是IP地址
209}
210 var host = convert_addr(ipaddr);
211 var pat = convert_addr(pattern);
212 var mask = convert_addr(maskstr); $(b&b; 213)return((host& mask)==(pat& mask));
214
215}

希望有帮助!


In FireFox internet connection is made through a proxy auto config file "something.pac"

How do I know for a certain URL which proxy server is being used?

Thanks.

解决方案

.pac file is just an emca script - aka JavaScript. Check out the wikipedia article on the file format.

If you copy the PAC code you can process it to see what proxy is being used based on the target url. If you are feeling fancy, you can wrap the script into a web page (locally) to create a tool to evaluate locally.

Edit:

As an alternative to the method I started recommending, you might check out PACTester, available on Google Code. This will allow you to quickly test a range of options.

If you have .Net available and are interested in playing with C# then you can check out this article on MSDN which has code you can use in a similar fashion to the above.

To expand on the original method outlined above, there are a number of functions which may (and typically are) provided by the host browser. The basic function which must be implemented in a pac file is FindProxyForUrl(). This accepts two parameters: the url and the host (the host derived from the name of url). The "provided" functions include: isInNet(), localHostOrDomainIs(), isPlainHostName(), isResolvable(), etc.

If you are working in a Microsoft environment then you can check out this page on Technet which describes the .pac format with some useful examples.

Per the Microsoft documentation for isInNet():

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).

If you want to get technical, here is the Mozilla source code for the implementation of proxy auto-config related services. It specifies the JS code for isInNet() as:

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 }

Hope that helps!

这篇关于如何发现在pac中使用de代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆