forked from fangdingjun/gfwlist2pac
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpac.tmpl
More file actions
executable file
·33 lines (28 loc) · 836 Bytes
/
pac.tmpl
File metadata and controls
executable file
·33 lines (28 loc) · 836 Bytes
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
var domains = {
{{ range $index, $value := .Domains}}
"{{ $index }}": {{ $value }},{{ end}}
{{ with .Custom}}{{range $ii, $vv := .}}
"{{$ii}}": {{$vv}},{{end}}{{end}}
"__THE_END__": 1
};
var proxy = "{{ .Proxy }}; DIRECT;";
var direct = 'DIRECT;';
var hasOwnProperty = Object.hasOwnProperty;
function FindProxyForURL(url, host) {
var suffix;
var pos = host.lastIndexOf('.');
while(1) {
pos = host.lastIndexOf('.', pos - 1);
if (pos <= 0) {
if (hasOwnProperty.call(domains, host)) {
return proxy;
} else {
return direct;
}
}
suffix = host.substring(pos + 1);
if (hasOwnProperty.call(domains, suffix)) {
return proxy;
}
}
}