Forum Moderators: open
I'm trying to set up a PAC for laptop users in my school, along these lines:
IF domain is PlainHostName or a .blah.blah.uk domain or a certain IP address or range, it should be direct
IF my IP is 192.168.1.*, connection is direct
otherwise, proxy 10.137.166.4:8080
I've got this code, which is failing...
---------------------------------------------
function FindProxyForURL(url, host)
{
if (isPlainHostName(host) ¦¦
dnsDomainIs(host, ".blah.blah.uk") ¦¦
dnsDomainIs(host, ".blah.blah.uk") ¦¦
(isInNet(host, "10.225.64.10")) ¦¦
(isInNet(host, "10.137.166.*")))
{ return "DIRECT" }
else if (isInNet(myIpAddress(), "192.168.1.*", "255.255.255.0"))
{ return "DIRECT" }
else
return "PROXY 10.137.166.4:8080";
it looks like isInNet is looking for 3 arguments but you only have 2. It looks like you have to add the mask:
from the link:
isInNet(host, pattern, mask)host
a DNS hostname, or IP address. If a hostname is passed, it will be resoved into an IP address by this function.
pattern
an IP address pattern in the dot-separated format
mask
mask for the IP address pattern informing which parts of the IP address should be matched against. 0 means ignore, 255 means match.True iff the IP address of the host matches the specified IP address pattern.
Pattern and mask specification is done the same way as for SOCKS configuration.
Examples:isInNet(host, "198.95.249.79", "255.255.255.255")
is true iff the IP address of host matches exactly 198.95.249.79.
isInNet(host, "198.95.0.0", "255.255.0.0")
is true iff the IP address of the host matches 198.95.*.*.
it also looks like it is expecting 0 rather than * so this:
(isInNet(host, "10.225.64.10")) ¦¦
(isInNet(host, "10.137.166.*")))
looks like it should be:
(isInNet(host, "10.225.64.10","255.255.255.255")) ¦¦
(isInNet(host, "10.137.166.0","255.255.255.0")))
and this:
else if (isInNet(myIpAddress(), "192.168.1.*", "255.255.255.0"))
looks like it should be:
else if (isInNet(myIpAddress(), "192.168.1.0", "255.255.255.0"))
here is some more good reading on wikipedia:
[en.wikipedia.org...]
i've never created a .pac file before, hope this gets you going in the right direction.
function FindProxyForURL(url, host)
{
if (shExpMatch(host, "*.blah.blah.uk") ¦¦
shExpMatch(host, "*.blah.blah.uk") ¦¦
isInNet(host, "10.225.64.10", "255.255.255.255") ¦¦
isInNet(host, "10.137.166.0", "255.255.255.0") ¦¦
isInNet(myIpAddress(), "192.168.1.*", "255.255.255.0") ¦¦
isPlainHostName(host))
return "DIRECT";
else
return "PROXY 10.137.166.4:8080";
}