Инструменты пользователя

Инструменты сайта


unix:wpad-dat-samples

Примеры wpad.dat

Мой wpad.dat ПУ51

Машинам компьютерного классы выдается dansguardian. Остальным просто наш прокси.

function FindProxyForURL(url, host) {
    var myip = myIpAddress();
    var octets = myip.split(".");
    var last_octet = parseInt(octets[3]);
 
    if((last_octet > 150) && (last_octet < 159)) {
        return "PROXY 192.168.0.254:8080";
    } else {
        if(isPlainHostName(host)
                || dnsDomainIs(host, "pu51.alx")
                || isInNet(host, "192.168.0.0", "255.255.255.0")) {
            return "DIRECT";
        } else {
            return "PROXY 192.168.0.254:3128";
        }
    }
 
} // END FindProxyForURL

Некоторая балансировка нагрузки

function FindProxyForURL(url, host) {
    var myip = myIpAddress();
    var my_addr_array = myip.split(".");
    var mysubnet = parseInt(my_addr_array[2]);
 
    if ((mysubnet >= 200) && (mysubnet < = 209)) {
        proxy = "PROXY execproxy.company.com:8000");
    }
    else {
        proxy = "PROXY proxy.company.com:8000";
    }
 
    return proxy;
}

Еще некоторая балансировка

function FindProxyForURL(url, host) {
    var myip = myIpAddress()
    var ipbits = myip.split(".")
    var myseg = parseInt(ipbits[3])
 
    if (myseg == Math.floor(myseg/2)*2) {
        // Для четных
        proxy = "PROXY p1.company.com:8080; PROXY p2.company.com:8080";
    }
    else {
        // Для не четных
        proxy = "PROXY p2.company.com:8080; PROXY p1.company.com:8080";
    }
 
    return proxy;
}

Отладка кода

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";
}
unix/wpad-dat-samples.txt · Последнее изменение: 2024/05/02 13:20 — 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki