mirror of
https://github.com/iBug/pac.git
synced 2025-07-13 21:02:16 +08:00
Last maintenance to this repository, see README
This commit is contained in:
parent
ae818242af
commit
fa0ad38cdf
@ -1,5 +1,9 @@
|
||||
# pac
|
||||
|
||||
PAC scripts for proxies.
|
||||
PAC scripts for proxies
|
||||
|
||||
To generate PAC from the latest IP range list, run `./build.sh` (make sure you have `wget` and Python 3 available).
|
||||
## 使用
|
||||
|
||||
为了方便大家生成与使用,我制作了一个网页版的生成器:<https://ibugone.com/cn/pac-generator>,可以直接在线生成并下载。
|
||||
|
||||
网页生成器的源代码[在这](https://github.com/iBug/iBug-source/blob/master/_cn/pac-generator.md),同时本仓库中的代码停止维护。
|
||||
|
7
build.sh
7
build.sh
@ -3,13 +3,6 @@
|
||||
SOURCE="http://www.ipdeny.com/ipblocks/data/aggregated/cn-aggregated.zone"
|
||||
|
||||
wget -O ip_ranges.txt "$SOURCE"
|
||||
cat >> ip_ranges.txt <<EOF
|
||||
10.0.0.0/8
|
||||
127.0.0.0/16
|
||||
169.254.0.0/16
|
||||
172.16.0.0/12
|
||||
192.168.0.0/16
|
||||
EOF
|
||||
python3 ranges_to_js.py > tmp.js
|
||||
cat code.js tmp.js > out.pac
|
||||
rm tmp.js
|
||||
|
25
code.js
25
code.js
@ -23,18 +23,31 @@ function belongsToSubnet(host, list) {
|
||||
return (masked ^ list[x][0]) == 0;
|
||||
}
|
||||
|
||||
var proxy = "__PROXY__";
|
||||
var direct = "DIRECT";
|
||||
function isChina(host) {
|
||||
return belongsToSubnet(host, CHINA);
|
||||
}
|
||||
|
||||
function isLan(host) {
|
||||
return belongsToSubnet(host, LAN);
|
||||
}
|
||||
|
||||
function FindProxyForURL(url, host) {
|
||||
var remote = dnsResolve(host);
|
||||
if (belongsToSubnet(remote, WHITELIST)) {
|
||||
return direct;
|
||||
if (isLan(remote) || isChina(remote)) {
|
||||
return "DIRECT";
|
||||
}
|
||||
return proxy;
|
||||
return "__PROXY__";
|
||||
}
|
||||
|
||||
// Format: [Hex IP, mask]
|
||||
// e.g. 1.0.1.0/24 = [0x80008000, 0xFFFFFF00]
|
||||
// e.g. 1.0.1.0/24 = [0x01000100, 0xFFFFFF00]
|
||||
// Source: http://www.ipdeny.com/ipblocks/data/aggregated/cn-aggregated.zone
|
||||
|
||||
var LAN = [
|
||||
[0x0A000000, 0xFF000000],
|
||||
[0x7F000000, 0xFFFFFF00],
|
||||
[0xA9FE0000, 0xFFFF0000],
|
||||
[0xAC100000, 0xFFF00000],
|
||||
[0xC0A80000, 0xFFFF0000]
|
||||
];
|
||||
|
||||
|
@ -883,7 +883,10 @@
|
||||
101.2.172.0/22
|
||||
101.4.0.0/14
|
||||
101.16.0.0/12
|
||||
101.32.0.0/12
|
||||
101.33.128.0/17
|
||||
101.34.0.0/15
|
||||
101.36.0.0/14
|
||||
101.40.0.0/13
|
||||
101.48.0.0/15
|
||||
101.50.8.0/21
|
||||
101.50.56.0/22
|
||||
@ -2034,7 +2037,6 @@
|
||||
103.126.208.0/22
|
||||
103.126.241.0/24
|
||||
103.129.52.0/22
|
||||
103.129.148.0/22
|
||||
103.130.132.0/22
|
||||
103.130.152.0/24
|
||||
103.130.160.0/22
|
||||
@ -2155,6 +2157,17 @@
|
||||
103.144.88.0/24
|
||||
103.144.108.0/23
|
||||
103.144.136.0/23
|
||||
103.144.148.0/23
|
||||
103.144.158.0/23
|
||||
103.144.240.0/23
|
||||
103.145.38.0/23
|
||||
103.145.40.0/22
|
||||
103.145.60.0/23
|
||||
103.145.72.0/23
|
||||
103.145.80.0/23
|
||||
103.145.86.0/23
|
||||
103.145.92.0/22
|
||||
103.145.98.0/23
|
||||
103.192.0.0/19
|
||||
103.192.48.0/21
|
||||
103.192.56.0/22
|
||||
@ -5227,8 +5240,3 @@
|
||||
223.255.0.0/17
|
||||
223.255.236.0/22
|
||||
223.255.252.0/23
|
||||
10.0.0.0/8
|
||||
127.0.0.0/16
|
||||
129.254.0.0/16
|
||||
172.16.0.0/12
|
||||
192.168.0.0/16
|
||||
|
@ -18,6 +18,6 @@ data = [(ip_to_num(s), n_to_mask(int(n))) for s, n in pairs]
|
||||
data = sorted(data, key=lambda x: x[0])
|
||||
|
||||
out = ",\n".join([" [{}, {}]".format(to_upper_hex(a), to_upper_hex(b)) for a, b in data])
|
||||
out = "var WHITELIST = [\n" + out + "\n];"
|
||||
out = "var CHINA = [\n" + out + "\n];"
|
||||
|
||||
print(out)
|
||||
|
Loading…
Reference in New Issue
Block a user