How to open proxy server used in pac

In FireFox, Internet connection is through a proxy file with the automatic configuration of "something.pac"

How do I know which URL is used by the proxy server?

Thanks.

+8
firefox proxy
source share
2 answers

A .pac file is just ECMAscript - it's JavaScript. Check out the Wikipedia article on file format.

If you copy the PAC code, you can process it to see which proxy is used based on the destination URL. If you like, you can put the script in a web page (locally) to create a tool for local evaluation.

Edit:

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

If you have .Net available and want to play with C #, you can check out this article on MSDN, which has code that you can use as described above.

To extend the original method described above, there are a number of functions that can (and usually) are provided by the host browser. The main function to be implemented in the pac file is FindProxyForUrl() . This takes two parameters: URL and host (host derived from the name of the URL). The "provided" functions include: isInNet() , localHostOrDomainIs() , isPlainHostName() , isResolvable() , etc.

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

According to Microsoft documentation for isInNet() :

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

If you want technical information, here is the Mozilla source code for implementing services related to automatic proxy configuration. It defines 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 this helps!

+7
source share

I created a simple proxy page with an HTML page:

 <html> <head> <script type="text/javascript"> function myIpAddress() { return "192.168.1.2"; // Your IP } function isInNet(ipaddr, pattern, maskstr) { var test = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/(ipaddr); if (test == null) { ipaddr = dnsResolve(ipaddr); if (ipaddr == null) return false; } else if (test[1] > 255 || test[2] > 255 || test[3] > 255 || test[4] > 255) { return false; // not an IP address } var host = convert_addr(ipaddr); var pat = convert_addr(pattern); var mask = convert_addr(maskstr); return ((host & mask) == (pat & mask)); } function dnsResolve(host) { try { return dns.resolve(host, 0).getNextAddrAsString(); } catch (e) { return null; } } function convert_addr(ipchars) { var bytes = ipchars.split('.'); var result = ((bytes[0] & 0xff) << 24) | ((bytes[1] & 0xff) << 16) | ((bytes[2] & 0xff) << 8) | (bytes[3] & 0xff); return result; } function isPlainHostName(host) { return host.search('\\\\.') == -1; } function shExpMatch(url, pattern) { pattern = pattern.replace(/\\./g, '\\\\.'); pattern = pattern.replace(/\\*/g, '.*'); pattern = pattern.replace(/\\?/g, '.'); var newRe = new RegExp('^' + pattern + '$'); return newRe.test(url); } function dnsDomainIs(host, domain) { return host.length >= domain.length && host.substring(host.length - domain.length) == domain; } </script> <!-- Your proxy script --> <script type="text/javascript" src="webproxy.js"></script> </head> <body> Host: <input id="host"/><br/> URL: <input id="url"/><br/> Proxy: <input id="proxy" disabled="disabled"/><br/> <input type="button" value="Resolve" onclick="document.getElementById('proxy').value = FindProxyForURL(document.getElementById('host').value, document.getElementById('url').value)"/><br/> </body> </html> 

Code for myIpAddress, etc. I have mozilla sources.

+5
source share

All Articles