Last active
October 16, 2015 12:30
-
-
Save hvdkooij/30e90b62c42993a748d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ProxyPAC example | |
// Don't use it without modifications to the tables. | |
// Direct domain names | |
// List of domains that do need to go through the proxy | |
var Direct = new Array( | |
"*.example.com", | |
"example.com", | |
"*.example.net", | |
"example.net", | |
"*.logmeinrescue.com", | |
"webex.com", | |
"*.webex.com" | |
); | |
// Local Networks | |
// List of networks that can connected without the proxy | |
var LocalNets = [ | |
["127.0.0.0", "255.0.0.0"], | |
["10.0.0.0", "255.0.0.0"], | |
["172.16.0.0","255.240.0.0"], | |
["172.16.0.0","255.240.0.0"], | |
["169.254.0.0", "255.255.0.0"] | |
]; | |
// Client Networks | |
// Proxy should only be used when part of one of these networks | |
var ClientNets = [ | |
["172.16.16.0","255.255.255.0"], | |
["172.31.55.0","255.255.255.0"] | |
]; | |
// Proxies go here: | |
// Use domain names if you want to use Kerberos !!! | |
var PROXYODD = "PROXY proxy.example.net:80"; | |
var PROXYEVEN = "PROXY proxy.example.com:8080"; | |
var NOPROXY = "DIRECT"; | |
// Now select my proxy | |
function FindProxyForURL(url, host) { | |
// Odd or Even: | |
var myIP = myIpAddress(); | |
var myOctet = myIP.split("."); | |
var myHost = parseInt(myOctet[3]); | |
var Even = (myHost===Math.floor(myHost/2)*2); | |
// Direct names go direct | |
if(isPlainHostName(host)) { | |
return NOPROXY; | |
} | |
// RealPlayer & MediaPlayer | |
// We don't want to feed these protocols through a proxy | |
var urllower = url.toLowerCase(); | |
if((urllower.substring(0,5)=="rtsp:") || | |
(urllower.substring(0,6)=="rtspt:") || | |
(urllower.substring(0,6)=="rtspu:") || | |
(urllower.substring(0,4)=="mms:") || | |
(urllower.substring(0,5)=="mmst:") || | |
(urllower.substring(0,5)=="mmsu:")) | |
return NOPROXY; | |
// Direct | |
for (var loop=0; loop<Direct.length; loop++) { | |
var checksite = Direct[loop]; | |
if (shExpMatch(host, checksite)) { | |
return NOPROXY; | |
} | |
} | |
// LocalNets | |
var HostIP = dnsResolve(host); | |
for (var loop=0; loop<LocalNets.length; loop++) { | |
var Network = LocalNets[loop][0]; | |
var SubnetMask = LocalNets[loop][1]; | |
if (isInNet(HostIP, Network, SubnetMask)) { | |
return NOPROXY; | |
} | |
} | |
// WE ARE DONE HERE | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment