forked from coova/coova-chilli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwpad.dat.in
62 lines (53 loc) · 1.86 KB
/
wpad.dat.in
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
. @SYSCONFDIR@/chilli/functions
# See http://findproxyforurl.com/example-pac-file/
#
#// If the hostname matches, send direct.
# if (dnsDomainIs(host, "intranet.domain.com") ||
# shExpMatch(host, "abcdomain.com"))
# return "DIRECT";
#
#// If the protocol or URL matches, send direct.
# if (url.substring(0, 4)=="ftp:" ||
# shExpMatch(url, "http://abcdomain.com/folder/*"))
# return "DIRECT";
#
#// If the requested website is hosted within the internal network, send direct.
# if (isPlainHostName(host) ||
# shExpMatch(host, "*.local") ||
# isInNet(dnsResolve(host), "10.0.0.0", "255.0.0.0") ||
# isInNet(dnsResolve(host), "172.16.0.0", "255.240.0.0") ||
# isInNet(dnsResolve(host), "192.168.0.0", "255.255.0.0") ||
# isInNet(dnsResolve(host), "127.0.0.0", "255.255.255.0"))
# return "DIRECT";
#
#// If the IP address of the local machine is within a defined
#// subnet, send to a specific proxy.
# if (isInNet(myIpAddress(), "10.10.5.0", "255.255.255.0"))
# return "PROXY 1.2.3.4:8080";
#
#// DEFAULT RULE: All other traffic, use below proxies, in fail-over order.
# return "PROXY 4.5.6.7:8080; PROXY 7.8.9.10:8080";
if [ "$HS_WPAD_PROXY" != "" ]
then
DEFAULT_PROXY="PROXY $HS_WPAD_PROXY; DIRECT";
else
DEFAULT_PROXY="DIRECT";
fi
echo -n "HTTP/1.0 200 OK\r\n"
echo -n "Content-Type: application/x-ns-proxy-autoconfig\r\n"
echo -n "Connection: close\r\n"
echo -n "Cache: none\r\n"
echo -n "\r\n\r\n"
cat<<_EOF_
function FindProxyForURL(url, host) {
if (isPlainHostName(host) ||
shExpMatch(host, "*.local") ||
shExpMatch(host, "*.$HS_DOMAIN") ||
isInNet(dnsResolve(host), "$HS_NETWORK", "$HS_NETMASK"))
return "DIRECT";
if (isInNet(myIpAddress(), "$HS_NETWORK", "$HS_NETMASK"))
return "DIRECT";
return "$DEFAULT_PROXY";
}
_EOF_