案例分享

如何Debug

可以将如下代码加入pac文件中以用于问题定位
这里只能用IE6老版本进行定位,目前主流浏览器不支持

function FindProxyForURL(url, host) {

    debugPAC ="PAC Debug Information\n";
    debugPAC +="-----------------------------------\n";
    debugPAC +="Machine IP: " + myIpAddress() + "\n";
    debugPAC +="Hostname: " + host + "\n";
    if (isResolvable(host)) {resolvableHost = "True"} else {resolvableHost = "False"};
    debugPAC +="Host Resolvable: " + resolvableHost + "\n";
    debugPAC +="Hostname IP: " + dnsResolve(host) + "\n";
    if (isPlainHostName(host)) {plainHost = "True"} else {plainHost = "False"};
    debugPAC +="Plain Hostname: " + plainHost + "\n";
    debugPAC +="Domain Levels: " + dnsDomainLevels(host) + "\n";
    debugPAC +="URL: " + url + "\n";

    // Protocol can only be determined by reading the entire URL.
    if (url.substring(0,5)=="http:") {protocol="HTTP";} else
        if (url.substring(0,6)=="https:") {protocol="HTTPS";} else
            if (url.substring(0,4)=="ftp:") {protocol="FTP";}
                else {protocol="Unknown";}
    debugPAC +="Protocol: " + protocol + "\n";

    // Reduce volume of alerts to a useable level, e.g. only alert on static text pages.
    if (!shExpMatch(url,"*.(js|xml|ico|gif|png|jpg|jpeg|css|swf)*")) {alert(debugPAC);}

    return "DIRECT";
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
更新时间: