我的笔记本在办公室需要代理上网,而家里不需要,每次都需要更改配置。
于是写了一个脚本:
function FindProxyForURL(url, host)
{
//if (!isResolvable("xxx.mycomany.com"))
// return "DIRECT";
if (isInNet(myIpAddress(),"192.168.1.0", "255.255.255.0"))
return "DIRECT";
return "PROXY 172.19.28.42:8080";
}
假如本地ip地址是 192.168.1.XXX 则是在家直连上网,否则使用公司的代理服务器
保存成文件。
在Firefox或者IE配置一下就可以了
结果发现firefox判断本地ip地址你那里有问题。找了下资料,原来是 myIpAddress() 函数返回了ipv6格式的地址,配置一下firefox , 在地址栏输入 about:config ,修改 network.dns.disableIPv6 为 ture . 问题解决了!