取消从gfwlist获取域名;更新cnip到最新;精简自定义域名;
This commit is contained in:
24
README.md
24
README.md
@@ -1,6 +1,6 @@
|
|||||||
# gfw-pac
|
# gfw-pac
|
||||||
|
|
||||||
科学上网。通过 gfwlist 和中国 IP 地址生成 PAC(Proxy auto-config) 文件。对存在于 gfwlist 的域名和解析出的 IP 在国外的域名使用代理。
|
科学上网 PAC 文件生成器。通过自定义域名和中国 IP 地址生成 PAC(Proxy auto-config) 文件。对存在于自定义域名和解析出的 IP 在国外的域名使用代理。
|
||||||
|
|
||||||
## 特性
|
## 特性
|
||||||
* 速度快,优先按域名匹配,再按解析后的 IP 匹配
|
* 速度快,优先按域名匹配,再按解析后的 IP 匹配
|
||||||
@@ -15,18 +15,17 @@
|
|||||||
|
|
||||||
## gfw-pac.py 使用说明
|
## gfw-pac.py 使用说明
|
||||||
|
|
||||||
usage: gfw-pac.py -f PAC -p PROXY [-h] [-i GFWLIST_FILE]
|
usage: gfw-pac.py -f 输出的PAC文件名 -p 代理服务器 [-h]
|
||||||
[--user-rule USER_RULE_FILE]
|
[--user-rule 自定义使用代理域名的文件]
|
||||||
[--direct-rule DIRECT_RULE_FILE]
|
[--direct-rule 自定义直连域名域名的文件]
|
||||||
[--localtld-rule LOCAL_TLD_RULE_FILE]
|
[--localtld-rule 本地TLD文件]
|
||||||
[--ip-file IP_FILE]
|
[--ip-file APNIC下载的delegated文件]
|
||||||
|
|
||||||
参数说明:
|
参数说明:
|
||||||
|
|
||||||
-h 显示帮助
|
-h 显示帮助
|
||||||
-i 指定本地 gfwlist 文件,若不指定则自动下载
|
|
||||||
-f (必须)输出的 pac 文件
|
-f (必须)输出的 pac 文件
|
||||||
-p (必须)指定代理服务器
|
-p (必须)指定代理服务器,例如 PROXY 192.168.1.1:3128
|
||||||
--user-rule 自定义使用代理的域名文件,文件里每行一个域名
|
--user-rule 自定义使用代理的域名文件,文件里每行一个域名
|
||||||
--direct-rule 自定义不使用代理的域名文件,文件里每行一个域名
|
--direct-rule 自定义不使用代理的域名文件,文件里每行一个域名
|
||||||
--localtld-rule 自定义不使用代理的顶级域,文件里每行一个域名,必须带前导圆点(例如 .test)
|
--localtld-rule 自定义不使用代理的顶级域,文件里每行一个域名,必须带前导圆点(例如 .test)
|
||||||
@@ -34,14 +33,15 @@
|
|||||||
|
|
||||||
举例:
|
举例:
|
||||||
|
|
||||||
./gfw-pac.py -i gfwlist.txt \
|
./gfw-pac.py -f gfw.pac \
|
||||||
-f gfw.pac \
|
|
||||||
-p "PROXY 192.168.1.200:3128; DIRECT" \
|
-p "PROXY 192.168.1.200:3128; DIRECT" \
|
||||||
--user-rule=custom-domains.txt \
|
--user-rule=custom-domains.txt \
|
||||||
--direct-rule=direct-domains.txt \
|
--direct-rule=direct-domains.txt \
|
||||||
--localtld-rule=local-tlds.txt \
|
--localtld-rule=local-tlds.txt \
|
||||||
--ip-file=delegated-apnic-latest.txt
|
--ip-file=delegated-apnic-latest.txt
|
||||||
|
|
||||||
## 疑难解答
|
## 技巧
|
||||||
|
|
||||||
若自动下载 APNIC 的 IP 分配文件很慢,可自行用科学办法下载 <http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest> 后,用 `--ip-file` 参数指定下载好的文件。同理 gfwlist 从 <https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt> 下载后用 `-i` 参数指定。
|
* 若自动下载 APNIC 的 IP 分配文件很慢,可自行用科学办法下载 <https://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest> 后,用 `--ip-file` 参数指定下载好的文件。
|
||||||
|
* 自行解决 DNS 污染问题。
|
||||||
|
* 代理工具最好也配置 GEOIP 规则。
|
||||||
@@ -6,43 +6,11 @@ google-analytics.com
|
|||||||
googleadservices.com
|
googleadservices.com
|
||||||
googlesyndication.com
|
googlesyndication.com
|
||||||
googleadsserving.cn
|
googleadsserving.cn
|
||||||
doubleclick.net
|
|
||||||
wikipedia.org
|
wikipedia.org
|
||||||
stackoverflow.com
|
stackoverflow.com
|
||||||
sstatic.net
|
githubusercontent.com
|
||||||
imgur.com
|
github.com
|
||||||
googlecode.com
|
|
||||||
docker.io
|
|
||||||
docker.com
|
|
||||||
angularjs.org
|
|
||||||
rsyslog.com
|
|
||||||
gerhards.net
|
|
||||||
chrome.com
|
|
||||||
digicert.com
|
|
||||||
typekit.net
|
|
||||||
wordpress.com
|
|
||||||
aolcdn.com
|
|
||||||
wp.com
|
|
||||||
ifixit.com
|
|
||||||
atlassian.com
|
|
||||||
amazonaws.com
|
|
||||||
cloudfront.net
|
|
||||||
trello.com
|
|
||||||
appelsiini.net
|
|
||||||
angularjs.org
|
|
||||||
mplxtms.com
|
|
||||||
slack.com
|
|
||||||
fastly.net
|
|
||||||
edgekey.net
|
|
||||||
discussions.apple.com
|
|
||||||
disquscdn.com
|
|
||||||
wenzhixin.net.cn
|
|
||||||
last.fm
|
|
||||||
scdn.co
|
|
||||||
spotify.com
|
|
||||||
spotilocal.com
|
|
||||||
ocsp.apple.com
|
|
||||||
raw.githubusercontent.com
|
|
||||||
bing.com
|
bing.com
|
||||||
microsoft.com
|
bing.cn
|
||||||
|
bing.net
|
||||||
live.com
|
live.com
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,383 +1,17 @@
|
|||||||
10010.com
|
|
||||||
115.com
|
|
||||||
123u.com
|
|
||||||
126.com
|
|
||||||
126.net
|
|
||||||
163.com
|
|
||||||
17173.com
|
|
||||||
178.com
|
|
||||||
17cdn.com
|
|
||||||
21cn.com
|
|
||||||
2288.org
|
|
||||||
3322.org
|
|
||||||
360buy.com
|
|
||||||
360buyimg.com
|
|
||||||
360doc.com
|
|
||||||
360safe.com
|
|
||||||
36kr.com
|
|
||||||
400gb.com
|
|
||||||
4399.com
|
|
||||||
51.la
|
|
||||||
51buy.com
|
|
||||||
51cto.com
|
|
||||||
51job.com
|
|
||||||
51jobcdn.com
|
|
||||||
5d6d.com
|
|
||||||
5d6d.net
|
|
||||||
61.com
|
|
||||||
6600.org
|
|
||||||
6rooms.com
|
|
||||||
7766.org
|
|
||||||
7k7k.com
|
|
||||||
8800.org
|
|
||||||
8866.org
|
|
||||||
90g.org
|
|
||||||
91.com
|
|
||||||
9966.org
|
|
||||||
acfun.tv
|
|
||||||
aicdn.com
|
|
||||||
ali213.net
|
|
||||||
alibaba.com
|
|
||||||
alicdn.com
|
|
||||||
aliexpress.com
|
|
||||||
aliimg.com
|
|
||||||
alikunlun.com
|
|
||||||
alimama.com
|
|
||||||
alipay.com
|
|
||||||
alipayobjects.com
|
|
||||||
alisoft.com
|
|
||||||
aliyun.com
|
aliyun.com
|
||||||
aliyuncdn.com
|
aliyuncdn.com
|
||||||
aliyuncs.com
|
aliyuncs.com
|
||||||
anzhi.com
|
|
||||||
appinn.com
|
|
||||||
apple.com
|
|
||||||
appsina.com
|
|
||||||
archlinuxcn.org
|
|
||||||
atpanel.com
|
|
||||||
baidu.com
|
baidu.com
|
||||||
baidupcs.com
|
baidupcs.com
|
||||||
baidustatic.com
|
baidustatic.com
|
||||||
baifendian.com
|
|
||||||
baihe.com
|
|
||||||
baixing.com
|
|
||||||
bdimg.com
|
bdimg.com
|
||||||
bdstatic.com
|
bdstatic.com
|
||||||
bilibili.tv
|
|
||||||
blogbus.com
|
|
||||||
blueidea.com
|
|
||||||
ccb.com
|
|
||||||
cctv.com
|
|
||||||
cctvpic.com
|
|
||||||
cdn20.com
|
|
||||||
china.com
|
|
||||||
chinabyte.com
|
|
||||||
chinacache.com
|
|
||||||
chinacache.net
|
|
||||||
chinacaipu.com
|
|
||||||
chinagba.com
|
|
||||||
chinahr.com
|
|
||||||
chinajoy.net
|
|
||||||
chinamobile.com
|
|
||||||
chinanetcenter.com
|
|
||||||
chinanews.com
|
|
||||||
chinapnr.com
|
|
||||||
chinaren.com
|
|
||||||
chinaspeeds.net
|
|
||||||
chinaunix.net
|
|
||||||
chinaz.com
|
|
||||||
chint.com
|
|
||||||
chiphell.com
|
|
||||||
chuangxin.com
|
|
||||||
ci123.com
|
|
||||||
ciku5.com
|
|
||||||
citysbs.com
|
|
||||||
class.coursera.org
|
|
||||||
cloudcdn.net
|
|
||||||
cmbchina.com
|
|
||||||
cmfu.com
|
|
||||||
cmread.com
|
|
||||||
cmwb.com
|
|
||||||
cn.archive.ubuntu.com
|
|
||||||
cn.coremetrics.com
|
|
||||||
cn.debian.org
|
|
||||||
cn.msn.com
|
|
||||||
cn
|
|
||||||
cnak2.englishtown.com
|
|
||||||
cnbeta.com
|
|
||||||
cnbetacdn.com
|
|
||||||
cnblogs.com
|
|
||||||
cnepub.com
|
|
||||||
cnzz.com
|
|
||||||
comsenz.com
|
|
||||||
csdn.net
|
|
||||||
ct10000.com
|
|
||||||
ctdisk.com
|
|
||||||
dangdang.com
|
|
||||||
dbank.com
|
dbank.com
|
||||||
dedecms.com
|
|
||||||
diandian.com
|
|
||||||
dianping.com
|
|
||||||
discuz.com
|
|
||||||
discuz.net
|
|
||||||
dl.google.com
|
|
||||||
docin.com
|
|
||||||
donews.com
|
|
||||||
dospy.com
|
|
||||||
douban.com
|
|
||||||
douban.fm
|
|
||||||
duapp.com
|
|
||||||
duba.net
|
|
||||||
duomi.com
|
|
||||||
duote.com
|
|
||||||
duowan.com
|
|
||||||
egou.com
|
|
||||||
et8.org
|
|
||||||
etao.com
|
|
||||||
f3322.org
|
|
||||||
fantong.com
|
|
||||||
fenzhi.com
|
|
||||||
fhldns.com
|
|
||||||
ganji.com
|
|
||||||
gaopeng.com
|
|
||||||
geekpark.net
|
|
||||||
gfan.com
|
|
||||||
gtimg.com
|
gtimg.com
|
||||||
hacdn.net
|
|
||||||
hadns.net
|
|
||||||
hao123.com
|
|
||||||
hao123img.com
|
|
||||||
hc360.com
|
|
||||||
hdslb.com
|
|
||||||
hexun.com
|
|
||||||
hiapk.com
|
|
||||||
hichina.com
|
|
||||||
hoopchina.com
|
|
||||||
huanqiu.com
|
|
||||||
hudong.com
|
|
||||||
huochepiao.com
|
|
||||||
hupu.com
|
|
||||||
iask.com
|
|
||||||
iciba.com
|
|
||||||
idqqimg.com
|
|
||||||
ifanr.com
|
|
||||||
ifeng.com
|
|
||||||
ifengimg.com
|
|
||||||
ijinshan.com
|
|
||||||
iqiyi.com
|
|
||||||
it168.com
|
|
||||||
itcpn.net
|
|
||||||
iteye.com
|
|
||||||
itouzi.com
|
|
||||||
jandan.net
|
|
||||||
jd.com
|
|
||||||
jiashule.com
|
|
||||||
jiasule.com
|
|
||||||
jiathis.com
|
|
||||||
jiayuan.com
|
|
||||||
jiepang.com
|
|
||||||
jing.fm
|
|
||||||
jobbole.com
|
|
||||||
jstv.com
|
|
||||||
jumei.com
|
|
||||||
kaixin001.com
|
|
||||||
kandian.com
|
|
||||||
kandian.net
|
|
||||||
kanimg.com
|
|
||||||
kankanews.com
|
|
||||||
kdnet.net
|
|
||||||
koudai8.com
|
|
||||||
ku6.com
|
|
||||||
ku6cdn.com
|
|
||||||
ku6img.com
|
|
||||||
kuaidi100.com
|
|
||||||
kugou.com
|
|
||||||
lashou.com
|
|
||||||
letao.com
|
|
||||||
letv.com
|
|
||||||
lietou.com
|
|
||||||
linezing.com
|
|
||||||
loli.mg
|
|
||||||
loli.vg
|
|
||||||
lvping.com
|
|
||||||
lxdns.com
|
|
||||||
mangocity.com
|
|
||||||
mapbar.com
|
|
||||||
mcbbs.net
|
|
||||||
mediav.com
|
|
||||||
meilishuo.com
|
|
||||||
meituan.com
|
|
||||||
meituan.net
|
|
||||||
meizu.com
|
|
||||||
miui.com
|
|
||||||
moe123.com
|
|
||||||
moegirl.org
|
|
||||||
mop.com
|
|
||||||
mtime.com
|
|
||||||
my-card.in
|
|
||||||
mydrivers.com
|
|
||||||
mzstatic.com
|
|
||||||
netease.com
|
|
||||||
newsmth.net
|
|
||||||
ngacn.cc
|
|
||||||
nuomi.com
|
|
||||||
okbuy.com
|
|
||||||
optaim.com
|
|
||||||
oschina.net
|
|
||||||
paipai.com
|
|
||||||
pcbeta.com
|
|
||||||
pchome.net
|
|
||||||
pcpop.com
|
|
||||||
pengyou.com
|
|
||||||
phoenixlzx.com
|
|
||||||
phpwind.net
|
|
||||||
pingan.com
|
|
||||||
pool.ntp.org
|
|
||||||
pplive.com
|
|
||||||
pps.tv
|
|
||||||
ppstream.com
|
|
||||||
pptv.com
|
|
||||||
pubyun.com
|
|
||||||
qhimg.com
|
|
||||||
qianlong.com
|
|
||||||
qidian.com
|
|
||||||
qingdaonews.com
|
|
||||||
qiniu.com
|
|
||||||
qiniudn.com
|
|
||||||
qiushibaike.com
|
|
||||||
qiyi.com
|
|
||||||
qiyipic.com
|
|
||||||
qq.com
|
qq.com
|
||||||
qqmail.com
|
|
||||||
qstatic.com
|
qstatic.com
|
||||||
qunar.com
|
|
||||||
qunarzz.com
|
|
||||||
qvbuy.com
|
|
||||||
renren.com
|
|
||||||
renrendai.com
|
|
||||||
rrfmn.com
|
|
||||||
rrimg.com
|
|
||||||
sanguosha.com
|
|
||||||
sdo.com
|
|
||||||
sina.com
|
|
||||||
sinaapp.com
|
|
||||||
sinaedge.com
|
|
||||||
sinaimg.com
|
|
||||||
sinajs.com
|
|
||||||
skycn.com
|
|
||||||
smzdm.com
|
|
||||||
sogou.com
|
|
||||||
sohu.com
|
|
||||||
soku.com
|
|
||||||
solidot.org
|
|
||||||
soso.com
|
|
||||||
soufun.com
|
|
||||||
soufunimg.com
|
|
||||||
staticfile.org
|
|
||||||
staticsdo.com
|
|
||||||
steamcn.com
|
|
||||||
suning.com
|
|
||||||
szzfgjj.com
|
|
||||||
tanx.com
|
|
||||||
taobao.com
|
taobao.com
|
||||||
taobaocdn.com
|
taobaocdn.com
|
||||||
tbcache.com
|
|
||||||
tdimg.com
|
|
||||||
tencent.com
|
|
||||||
tenpay.com
|
|
||||||
tgbus.com
|
|
||||||
thawte.com
|
|
||||||
tiancity.com
|
|
||||||
tianyaui.com
|
|
||||||
tiexue.net
|
|
||||||
tmall.com
|
tmall.com
|
||||||
tmcdn.net
|
tmcdn.net
|
||||||
tom.com
|
tb.cn
|
||||||
tomonline-inc.com
|
|
||||||
tuan800.com
|
|
||||||
tuan800.net
|
|
||||||
tuanimg.com
|
|
||||||
tudou.com
|
|
||||||
tudouui.com
|
|
||||||
tuniu.com
|
|
||||||
u148.net
|
|
||||||
u17.com
|
|
||||||
ubuntu.com
|
|
||||||
ucjoy.com
|
|
||||||
uni-marketers.com
|
|
||||||
unionpay.com
|
|
||||||
unionpaysecure.com
|
|
||||||
upaiyun.com
|
|
||||||
upyun.com
|
|
||||||
uusee.com
|
|
||||||
uuu9.com
|
|
||||||
vaikan.com
|
|
||||||
vancl.com
|
|
||||||
vcimg.com
|
|
||||||
verycd.com
|
|
||||||
wandoujia.com
|
|
||||||
wdjimg.com
|
|
||||||
weibo.com
|
|
||||||
weiphone.com
|
|
||||||
weiyun.com
|
|
||||||
west263.com
|
|
||||||
wrating.com
|
|
||||||
wscdns.com
|
|
||||||
wumii.com
|
|
||||||
xdcdn.net
|
|
||||||
xiachufang.com
|
|
||||||
xiami.com
|
|
||||||
xiami.net
|
|
||||||
xiaomi.com
|
|
||||||
xiaonei.com
|
|
||||||
xiazaiba.com
|
|
||||||
xici.net
|
|
||||||
xilu.com
|
|
||||||
xinhuanet.com
|
|
||||||
xinnet.com
|
|
||||||
xlpan.com
|
|
||||||
xn--fiqs8s
|
|
||||||
xnpic.com
|
|
||||||
xungou.com
|
|
||||||
xunlei.com
|
|
||||||
ydstatic.com
|
|
||||||
yesky.com
|
|
||||||
yeyou.com
|
|
||||||
yihaodian.com
|
|
||||||
yihaodianimg.com
|
|
||||||
yingjiesheng.com
|
|
||||||
yintai.com
|
|
||||||
yinyuetai.com
|
|
||||||
yiqifa.com
|
|
||||||
yixun.com
|
|
||||||
ykimg.com
|
|
||||||
ynet.com
|
|
||||||
youdao.com
|
|
||||||
yougou.com
|
|
||||||
youku.com
|
|
||||||
yupoo.com
|
|
||||||
yy.com
|
|
||||||
zbjimg.com
|
|
||||||
zhaopin.com
|
|
||||||
zhi.hu
|
|
||||||
zhihu.com
|
|
||||||
zhimg.com
|
|
||||||
zhubajie.com
|
|
||||||
zongheng.com
|
|
||||||
sinaimg.cn
|
|
||||||
icloud.com
|
|
||||||
apple.cn
|
|
||||||
weibocdn.com
|
|
||||||
tb.cn
|
|
||||||
jddebug.com
|
|
||||||
360hu.com
|
|
||||||
cmpassport.com
|
|
||||||
iqiyi.com
|
|
||||||
iqiyipic.com
|
|
||||||
qy.net
|
|
||||||
bdstatic.com
|
|
||||||
mmstat.com
|
|
||||||
taobao.com
|
|
||||||
alicdn.com
|
|
||||||
icloud.com.cn
|
|
||||||
icloud-content.com.cn
|
|
||||||
28
gfw-pac.py
28
gfw-pac.py
@@ -18,21 +18,18 @@ gfwlist_url = 'https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.
|
|||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
parser.add_argument('-i', '--input', dest='input',
|
|
||||||
help='path to gfwlist', metavar='GFWLIST')
|
|
||||||
parser.add_argument('-f', '--file', dest='output', required=True,
|
parser.add_argument('-f', '--file', dest='output', required=True,
|
||||||
help='path to output pac', metavar='PAC')
|
help='输出的PAC文件名', metavar='PAC')
|
||||||
parser.add_argument('-p', '--proxy', dest='proxy', required=True,
|
parser.add_argument('-p', '--proxy', dest='proxy', required=True,
|
||||||
help='the proxy parameter in the pac file, '
|
help='代理服务器, '
|
||||||
'for example, "SOCKS5 127.0.0.1:1080;"',
|
'例如, "PROXY 127.0.0.1:3128;"',
|
||||||
metavar='PROXY')
|
metavar='PROXY')
|
||||||
parser.add_argument('--user-rule', dest='user_rule',
|
parser.add_argument('--user-rule', dest='user_rule',
|
||||||
help='user rule file, which will be appended to'
|
help='直接通过代理域名的文件,每行一个')
|
||||||
' gfwlist')
|
|
||||||
parser.add_argument('--direct-rule', dest='direct_rule',
|
parser.add_argument('--direct-rule', dest='direct_rule',
|
||||||
help='user rule file, contains domains not bypass proxy')
|
help='直连的域名文件,每行一个')
|
||||||
parser.add_argument('--localtld-rule', dest='localtld_rule',
|
parser.add_argument('--localtld-rule', dest='localtld_rule',
|
||||||
help='local TLD rule file, contains TLDs with a leading dot not bypass proxy')
|
help='本地 TLD 规则文件, 不走代理, 每行一个,以 . 开头')
|
||||||
parser.add_argument('--ip-file', dest='ip_file',
|
parser.add_argument('--ip-file', dest='ip_file',
|
||||||
help='delegated-apnic-latest from apnic.net')
|
help='delegated-apnic-latest from apnic.net')
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
@@ -51,7 +48,7 @@ def fetch_ip_data():
|
|||||||
else:
|
else:
|
||||||
#fetch data from apnic
|
#fetch data from apnic
|
||||||
print("Fetching data from apnic.net, it might take a few minutes, please wait...")
|
print("Fetching data from apnic.net, it might take a few minutes, please wait...")
|
||||||
url=r'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest'
|
url=r'https://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest'
|
||||||
# url=r'http://flora/delegated-apnic-latest' #debug
|
# url=r'http://flora/delegated-apnic-latest' #debug
|
||||||
data=urllib.request.urlopen(url).read().decode('utf-8')
|
data=urllib.request.urlopen(url).read().decode('utf-8')
|
||||||
|
|
||||||
@@ -255,12 +252,6 @@ def main():
|
|||||||
user_rule = None
|
user_rule = None
|
||||||
direct_rule = None
|
direct_rule = None
|
||||||
localtld_rule = None
|
localtld_rule = None
|
||||||
if (args.input):
|
|
||||||
with open(args.input, 'r') as f:
|
|
||||||
content = f.read()
|
|
||||||
else:
|
|
||||||
print('Downloading gfwlist from %s' % gfwlist_url)
|
|
||||||
content = urllib.request.urlopen(gfwlist_url, timeout=10).read().decode('utf-8')
|
|
||||||
if args.user_rule:
|
if args.user_rule:
|
||||||
userrule_parts = urllib.parse.urlsplit(args.user_rule)
|
userrule_parts = urllib.parse.urlsplit(args.user_rule)
|
||||||
if not userrule_parts.scheme or not userrule_parts.netloc:
|
if not userrule_parts.scheme or not userrule_parts.netloc:
|
||||||
@@ -302,10 +293,7 @@ def main():
|
|||||||
|
|
||||||
cnips = fetch_ip_data()
|
cnips = fetch_ip_data()
|
||||||
|
|
||||||
content = decode_gfwlist(content)
|
domains = []
|
||||||
gfwlist = combine_lists(content, user_rule)
|
|
||||||
|
|
||||||
domains = parse_gfwlist(gfwlist)
|
|
||||||
# domains = reduce_domains(domains)
|
# domains = reduce_domains(domains)
|
||||||
pac_content = generate_pac_fast(domains, args.proxy, direct_rule, cnips, localtld_rule)
|
pac_content = generate_pac_fast(domains, args.proxy, direct_rule, cnips, localtld_rule)
|
||||||
|
|
||||||
|
|||||||
39
pac-template
39
pac-template
@@ -14,6 +14,40 @@ var hasOwnProperty = Object.hasOwnProperty;
|
|||||||
|
|
||||||
var ipRegExp = new RegExp(/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/);
|
var ipRegExp = new RegExp(/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/);
|
||||||
|
|
||||||
|
function isIPv6(ip) {
|
||||||
|
// Split the IP address into groups of hexadecimal digits
|
||||||
|
const groups = ip.split(':');
|
||||||
|
|
||||||
|
// An IPv6 address must have at least one group and at most 8 groups
|
||||||
|
if (groups.length < 1 || groups.length > 8) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that each group is a valid hexadecimal number
|
||||||
|
for (const group of groups) {
|
||||||
|
// Check that the group is not null, undefined, or an empty string before calling parseInt()
|
||||||
|
if (group === null || group === undefined || group === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use parseInt() to check if the group is a valid hexadecimal number
|
||||||
|
const value = parseInt(group, 16);
|
||||||
|
if (isNaN(value) || value < 0 || value > 0xFFFF) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the address contains a double colon, ensure that it appears only once
|
||||||
|
if (ip.includes('::')) {
|
||||||
|
if (ip.indexOf('::') !== ip.lastIndexOf('::')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The address is valid if it passes all the checks
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function convertAddress(ipchars) {
|
function convertAddress(ipchars) {
|
||||||
var bytes = ipchars.split('.');
|
var bytes = ipchars.split('.');
|
||||||
var result = ((bytes[0] & 0xff) << 24) |
|
var result = ((bytes[0] & 0xff) << 24) |
|
||||||
@@ -45,9 +79,6 @@ function testDomain(target, domains, cnRootIncluded) {
|
|||||||
var idxB = target.lastIndexOf('.', idxA - 1);
|
var idxB = target.lastIndexOf('.', idxA - 1);
|
||||||
var hasOwnProperty = Object.hasOwnProperty;
|
var hasOwnProperty = Object.hasOwnProperty;
|
||||||
var suffix = cnRootIncluded ? target.substring(idxA + 1) : '';
|
var suffix = cnRootIncluded ? target.substring(idxA + 1) : '';
|
||||||
if (suffix === 'cn') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (idxB === -1) {
|
if (idxB === -1) {
|
||||||
if (hasOwnProperty.call(domains, target)) {
|
if (hasOwnProperty.call(domains, target)) {
|
||||||
@@ -110,7 +141,7 @@ function FindProxyForURL(url, host) {
|
|||||||
if (!strIp) {
|
if (!strIp) {
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
intIp = convertAddress(strIp);
|
intIp = convertAddress(strIp);
|
||||||
|
|
||||||
if (match(intIp)) {
|
if (match(intIp)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user