Skip to content

Instantly share code, notes, and snippets.

@RayRoestenburg
Created March 17, 2010 12:14
Show Gist options
  • Save RayRoestenburg/335164 to your computer and use it in GitHub Desktop.
Save RayRoestenburg/335164 to your computer and use it in GitHub Desktop.
autoproxy pac file for company and home network
function FindProxyForURL(url, host) {
var lhost = host.toLowerCase();
var ip = myIpAddressEx();
// exclude localhost and some specific range on company network (123.45.*)
if ((lhost == "localhost")
|| (shExpMatch(lhost, "localhost.*"))
|| (lhost == "127.0.0.1")
|| shExpMatch(lhost, "123.45.*")) {
return "DIRECT";
}
var my_addresses = ip.split(";");
var found = false;
// check if the ipv4 or ipv6 addresses contain the company network ip's (123.45.*)
for(var i=0; i < my_addresses.length;++i){
if(isInNet(my_addresses[i], "123.45.0.0","255.255.0.0")) {
found = true;
break;
}
}
if(found) {
// use company proxy
return "PROXY 123.45.67.89:8080";
}
else {
//use direct connection
return "DIRECT";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment