So I'm working on a PAC file for proxying my internet connection. I've got several problems to overcome. First is that I've got multiple locations that I want to proxy. I'd like each location to proxy to a local server first, then to a secondary server that's at the central location, and finally if it can't talk to either of those 2 servers, go directly to mcafee. So here is the question, which is faster, doing something like this with a case statment
Or to run a big if/else statement using the "isInNet" method sort of like this:
I'm pretty sure that the switch is going to process faster, but wanted some input at the basic level before I got to the big question.
Thanks in advance.
Code:
function FindProxyForURL(url, host)
{
// Find your IP address
var myIP = myIpAddress();
// Split the IP address into segments
var ipbits = myIP.split(".");
// add the first 3 segments together to get a "network" 172.16.1 = 189, 192.168.2 = 362, 192.168.3 = 363, 192.168.4 = 364, etc...
var network = parseInt(ipbits[0])+parseInt(ipbits[1])+parseInt(ipbits[2]);
switch (network) {
case 189:
return "PROXY milwaukeeA:3128; PROXY milwaukeeB:3128; PROXY mydomain.com.interceptor02.mxlogic.net:8080";
break;
case 362:
return "PROXY springfiled:3128; PROXY milwaukeeB:3128; PROXY mydomain.com.interceptor02.mxlogic.net:8080";
break;
case 363:
return "PROXY atlanta:3128; PROXY milwaukeeB:3128; PROXY mydomain.com.interceptor02.mxlogic.net:8080";
break;
case 364:
return "PROXY chicago:3128; PROXY milwaukeeB:3128; PROXY mydomain.com.interceptor02.mxlogic.net:8080";
break;
default:
return "PROXY mydomain.com.interceptor02.mxlogic.net:8080";
}
}
Or to run a big if/else statement using the "isInNet" method sort of like this:
Code:
function FindProxyForURL(url, host)
{
var myIP = myIpAddress();
if(isInNet(myIP, "172.16.1.0", "255.255.255.0"))
{return "PROXY milwaukeeA:3128; PROXY milwaukeeB:3128; PROXY mydomain.com.interceptor02.mxlogic.net:8080";}
else if(isInNet(myIP, "192.168.2.0", "255.255.255.0"))
{return "PROXY springfiled:3128; PROXY milwaukeeB:3128; PROXY mydomain.com.interceptor02.mxlogic.net:8080";}
else if(isInNet(myIP, "192.168.3.0", "255.255.255.0"))
{return "PROXY atlanta:3128; PROXY milwaukeeB:3128; PROXY mydomain.com.interceptor02.mxlogic.net:8080";}
else if(isInNet(myIP, "192.168.4.0", "255.255.255.0"))
{return "PROXY chicago:3128; PROXY milwaukeeB:3128; PROXY mydomain.com.interceptor02.mxlogic.net:8080";}
else
{return "PROXY mydomain.com.interceptor02.mxlogic.net:8080";}
}
}
Thanks in advance.