Created
March 17, 2010 12:14
-
-
Save RayRoestenburg/335164 to your computer and use it in GitHub Desktop.
autoproxy pac file for company and home network
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
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