always thought that the Automatic Proxy Configuration script in IE nd other browsers was somethin complex.. but never really bothered about it, coz I never had to use it before.. I used to think that it's a shell script.. now that I got a hub, I can share my net conn b/w my laptop and home sys.. the only way I could find was to use a proxy at my home sys and use it from my laptop to connect to net..
but now came the horror of configuring a proxy every day at home and removin it @ office! I'd have to configure it every day at home and reset it @ the office, coz it's a direct conn @ office.. then I remembered abt this Automatic Proxy Configuration script and thought abt explorin it. after a lil googlin it turns out that it's a plain javascript function which returns a string which's the proxy url! it's damn simple.. here goes my script
function FindProxyForURL(url, host)
{
var proxyHost="172.16.10.71";
var httpProxyPort="808";
var ftpProxyPort="2121";
var sslProxyPort="808";
var gopherProxyPort="808";
var socksProxyPort="1080";
var telnetProxyPort="23";
var newsProxyPort="119";
if (url.substring(0, 5) == "http:") {
return "PROXY "+proxyHost+":"+httpProxyPort
+"; SOCKS "+proxyHost+":"
+socksProxyPort+"; DIRECT";
}
if (url.substring(0, 4) == "ftp:") {
return "PROXY "+proxyHost+":"+ftpProxyPort
+"; SOCKS "+proxyHost+":"
+socksProxyPort+"; DIRECT";
}
if (url.substring(0, 7) == "gopher:") {
return "PROXY "+proxyHost+":"+gopherProxyPort
+"; SOCKS "+proxyHost+":"
+socksProxyPort+"; DIRECT";
}
if (url.substring(0, 6) == "https:") {
return "PROXY "+proxyHost+":"+sslProxyPort
+"; SOCKS "+proxyHost+":"
+socksProxyPort+"; DIRECT";
}
if (url.substring(0, 6) == "telnet:") {
return "PROXY "+proxyHost+":"+telnetProxyPort
+"; SOCKS "+proxyHost+":"
+socksProxyPort+"; DIRECT";
}
if (url.substring(0, 6) == "news:") {
return "PROXY "+proxyHost+":"+newsProxyPort
+"; SOCKS "+proxyHost+":"
+socksProxyPort+"; DIRECT";
}
return "PROXY "+proxyHost+":"+httpProxyPort
+"; SOCKS "+proxyHost+":"
+socksProxyPort+"; DIRECT";
}
my home system is the proxy which gets the priority.. whenever it goes down, my laptop attempts a direct connection.. this's just perfect for me :)
this script works with both IE and Firefox.. not sure if there's anythin browser specific even here
oh! btw I forgot to add the links.. consult these for further details:
http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html
http://www.microsoft.com/technet/prodtechnol/ie/reskit/6/part6/c26ie6rk.mspx
No comments:
Post a Comment