Proxy Auto-Configuration

From My Notepad
Jump to: navigation, search

Auto Detect Methods

[1]

DHCP

DHCP Option 252 should be a string value of the following format: http://172.16.16.16/wpad.dat

DNS

If no DHCP option 252 is present, Microsoft Windows will query the host wpad.[domain_name_from_dhcp]. If the DNS record exists, Windows will attempt to download the file http://wpad.[domain]/wpad.dat or http://wpad/wpad.dat

Example wpad.dat

function FindProxyForURL(url, host)
{
    // Proxy server in format "PROXY [proxy server]:[proxy port]"
    var proxy = "PROXY 172.16.1.2:8080; DIRECT";

    if (isPlainHostName(host) || dnsDomainIs(host, ".domain.local"))
        return "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.255.224.0") ||
        isInNet(resolved_IP, "192.168.0.0", "255.255.0.0") ||
        isInNet(resolved_IP, "127.0.0.0", "255.0.0.0"))
        return "DIRECT";

    return proxy; // Connect via proxy
}

Testing: autoprox.exe

autoprox@Github

autoprox.exe

Usage:

autoprox.exe -p:wpad.dat -u:http://www.microsoft.com
autoprox.exe -p:wpad.dat -u:http://172.16.16.16

References

Mozilla Proxy Auto-Configuration (PAC) file