PAC

From Segfault
Jump to navigation Jump to search

Example

<source lang=javascript> // // proxy.pac // // MacOS, Safari: file://localhost/Users/alice/.proxy.pac // MacOS, Firefox: file:///Users/alice/.proxy.pac // Windows, Firefox: file:///C:/Documents%20and%20Settings/alice/Desktop/proxy.pac // function FindProxyForURL(url, host) {

if (      isInNet(host, "192.168.0.0","255.255.255.0")
       || isInNet(host, "127.0.0.0","255.0.0.0")
       || dnsDomainIs(host, "example.com")
       || dnsDomainIs(host, ".gov")
       || shExpMatch(url, "https:*")
       || url.substring(0, 6) == "https:"
       )
       return "DIRECT";
else if ( dnsDomainIs(host, "example.net")
       || dnsDomainIs(host, "example.org")
       )
       return "SOCKS 10.0.0.10:1080";
else  
       // Fallback to DIRECT if our proxy is not reachable
       return "PROXY proxy.local:8118; DIRECT";

} </source>

Pactester

Install pacparser, which contains the pactester too:

git clone https://github.com/pacparser/pacparser.git pacparser-git
cd pacparser-git
PREFIX=/opt/pacparser make -C src
sudo PREFIX=/opt/pacparser make -C src install

Usage:

$ pactester -p ~/.proxy.pac -u http://example.net
PROXY squid.local:3128

See also

Links