Skip to content

Instantly share code, notes, and snippets.

@Arcath
Created March 23, 2012 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arcath/2172289 to your computer and use it in GitHub Desktop.
Save Arcath/2172289 to your computer and use it in GitHub Desktop.
A Proxy PAC File for the traveling technician
function FindProxyForURL(url, host){
/* Lancashire Proxy */
proxy1 = "PROXY proxy.company1.com:8080; DIRECT";
/* Cumbria Proxy */
proxy2 = "PROXY proxy.company2.com:8080; DIRECT";
/* Set proxy to Direct as the default */
proxy = "DIRECT";
/* Range Arrays */
proxy1_ranges = ["10.1.2.0", "10.1.56.0", "10.56.98.0"];
proxy1_subnet = "255.255.255.0";
proxy2_ranges = ["10.2.40.0"];
proxy2_subnet = "255.255.255.0";
/* Specific Detection */
for(var i in proxy1_ranges){
if(isInNet(myIpAddress(), proxy1_ranges[i], proxy1_subnet)){
proxy = proxy1
iprange = proxy1_ranges[i]
subnet = proxy1_subnet
}
}
if(proxy == "DIRECT"){
for(var i in proxy2_ranges){
if(isInNet(myIpAddress(), proxy2_ranges[i], proxy2_subnet)){
proxy = proxy2
iprange = proxy2_ranges[i]
subnet = proxy2_subnet
}
}
}
if(proxy == proxy1 || proxy == proxy2){
if (isInNet(host, "127.0.0.0", "255.0.0.0") ||
isInNet(host, iprange, subnet) ||
isPlainHostName(host)){
proxy = "DIRECT";
}
}
/* Return */
return proxy
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment