文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>PAC File Examples

PAC File Examples

时间:2010-10-11  来源:Bnsen

PAC File Examples

Example 1

function FindProxyForURL(url, host) {

// If URL has no dots in host name, send traffic direct.
if (isPlainHostName(host))
return "DIRECT";

// If specific URL needs to bypass proxy, send traffic direct.
if (shExpMatch(url,"*domain.com*") ||
shExpMatch(url,"*vpn.domain.com*"))
return "DIRECT";

// If IP address is internal or hostname resolves to internal IP, send direct.

var resolved_ip = dnsResolve(host);

if (isInNet(resolved_ip, "10.0.0.0", "255.0.0.0") ||
isInNet(resolved_ip, "172.16.0.0", "255.240.0.0") ||
isInNet(resolved_ip, "192.168.0.0", "255.255.0.0") ||
isInNet(resolved_ip, "127.0.0.0", "255.255.255.0"))
return "DIRECT";

// If not on a internal/LAN IP address, send traffic direct.
if (!isInNet(myIpAddress(), "10.10.1.0", "255.255.255.0"))
return "DIRECT";

// All other traffic uses below proxies, in fail-over order.
return "PROXY 1.2.3.4:8080; PROXY 4.5.6.7:8080; DIRECT";

}

Example 2

function FindProxyForURL(url, host) {

// If IP address is internal or hostname resolves to internal IP, send direct.

var resolved_ip = dnsResolve(host);

if (isInNet(resolved_ip, "10.0.0.0", "255.0.0.0") ||
isInNet(resolved_ip, "172.16.0.0", "255.240.0.0") ||
isInNet(resolved_ip, "192.168.0.0", "255.255.0.0") ||
isInNet(resolved_ip, "127.0.0.0", "255.255.255.0"))
return "DIRECT";

// Use a different proxy for each protocol.
if (shExpMatch(url, "http:*")) return "PROXY proxy1.domain.com:3128";
if (shExpMatch(url, "https:*")) return "PROXY proxy2.domain.com:3128";
if (shExpMatch(url, "ftp:*")) return "PROXY proxy3.domain.com:3128";

}
相关阅读 更多 +
排行榜 更多 +
飙车地下城市赛车

飙车地下城市赛车

赛车竞速 下载
爬坡摩托

爬坡摩托

赛车竞速 下载
宝宝虚拟宠物

宝宝虚拟宠物

角色扮演 下载