-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproxy.pac
58 lines (48 loc) · 1.38 KB
/
proxy.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// My manually maintained personal PAC file
// I have two proxies at hand:
// 1. Purchased from rixCloud which has a quota of 40GB (maybe 20GB next year).
// 2. Private DigitalOcean free Droplet from GitHub education pack through kcptun.
var rixcloud = "SOCKS5 127.0.0.1:1086";
var digitalocean = "SOCKS5 127.0.0.1:1085";
// Direct access list in shell expression
var whitelist = [
".twofyw.me",
".yinxiang.com",
".baidu.com",
];
function isWhiteList(url, host) {
// Add more localhosts in the future
// How to match ip address?
if (isPlainHostName(host) || shExpMatch(host, "*.cn")) {
return true;
}
// Skip ip addresses
if (shExpMatch(host, "[0-9]*.[0-9]*.[0-9]*.[0-9]*")) {
return true;
}
// Search for hosts in the array whitelist
for (var i = 0; i < whitelist.length; i++) {
if (dnsDomainIs(host, whitelist[i])) {
return true;
}
}
return false;
}
function isYouTube(url, host) {
if (dnsDomainIs(host, ".youtube.com") || shExpMatch(url, "*.googlevideo.com/*")) {
return true;
}
}
function FindProxyForURL(url, host) {
// Skip local hosts and other white lists
if (isWhiteList(url, host)) {
return "DIRECT";
}
// Watch YouTube with DigitalOcean's (almost) unlimited network usage
// And all other networking goes through rixCloud
if (isYouTube(url, host)) {
return digitalocean;
} else {
return rixcloud;
}
}