-
Notifications
You must be signed in to change notification settings - Fork 9
/
amos.pac
44 lines (36 loc) · 1.17 KB
/
amos.pac
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
var direct = "DIRECT";
var http_proxy = "PROXY 127.0.0.1:12639";
var gfwed_list = ["oa.com", "woa.com", "tencent.com"];
var cn_list = ["qq.com", "taobao.com", "jd.com"];
var us_list = ["openai.com"];
var gfwed = {};
var cned = {};
var used = {};
for (var i = 0; i < gfwed_list.length; i += 1) {
gfwed[gfwed_list[i]] = true;
}
for (var i = 0; i < cn_list.length; i += 1) {
cned[cn_list[i]] = true;
}
for (var i = 0; i < us_list.length; i += 1) {
used[us_list[i]] = true;
}
function host2domain(host) {
var dotpos = host.lastIndexOf(".");
if (dotpos === -1) return host;
// Find the second last dot
dotpos = host.lastIndexOf(".", dotpos - 1);
if (dotpos === -1) return host;
return host.substring(dotpos + 1);
}
function FindProxyForURL(url, host) {
if (cned[host2domain(host)])
return "PROXY 127.0.0.1:8888";
if (used[host2domain(host)])
return "PROXY 100.110.32.130:8888";
if (isInNet(host, "11.0.0.0", "255.0.0.0") || isInNet(host, "9.0.0.0", "255.0.0.0") || isInNet(host, "30.0.0.0", "255.0.0.0")) {
return http_proxy;
}
// return http_proxy;
return gfwed[host2domain(host)] ? http_proxy : direct;
}