View Single Post
This can already be done by writing a proxy.pac file (which is actually written in javascript).

I'll offer up mine as an example, but lots of doco is available if you google... I've replaced stuff I don't want to share with XXX.

Code:
/**
 * On the 192.168.3.0 network, we need to use proxy 192.168.1.92:8080
 * to not get blocked by barracuda
 */
function FindProxyForURL(url, host)
{

    // if I can't resolve XXX, I'm probably at home. Return DIRECT.
    if (!isResolvable("XXX.XXX.edu.au")) {
        return "DIRECT";
    }
    
    // if the target is plain (no domain info), go DIRECT
    if (isPlainHostName(host) ||
        dnsDomainIs(host, ".stage") ||
        dnsDomainIs(host, ".test") ||
        dnsDomainIs(host, ".inside") ||
        dnsDomainIs(host, ".sydney") ||
        dnsDomainIs(host, ".XXX.edu.au") ||
        host == "127.0.0.1") {
        return "DIRECT";
    }

    
    // if the target host is within 192.168.0.0/16 or 203.2.XXX.0/24 return DIRECT
    if (isInNet(host, "192.168.0.0", "255.255.0.0") ||
        isInNet(host, "203.2.XXX.0", "255.255.255.0")){
        return "DIRECT";
    }

    // if we are getting something from theage.com.au, return the other proxy as .92 has issues
    if (dnsDomainIs(host, ".theage.com.au")) {
        return "PROXY 192.168.1.102:8080;DIRECT";
    }
    
    // otherwise return the proxy
    return "PROXY 192.168.1.92:8080;DIRECT";
    
}