Browse Source

feat: asset release script

dev
dnomd343 3 years ago
parent
commit
bc238330ec
  1. 6
      .gitignore
  2. 35
      asset/chinalist/build/build.py
  3. 20
      asset/chinalist/build/source-ip.sh
  4. 2
      asset/chinalist/build/source.sh
  5. 13
      asset/gfwlist/build/build.py
  6. 7
      asset/gfwlist/build/source.sh

6
.gitignore

@ -2,3 +2,9 @@
/bin/
/build/
/cmake-build-debug/
/asset/chinalist/china-ip.txt
/asset/chinalist/china-ip.txt.gz
/asset/chinalist/chinalist.txt
/asset/chinalist/chinalist.txt.gz
/asset/gfwlist/gfwlist.txt
/asset/gfwlist/gfwlist.txt.gz

35
asset/chinalist/build/build.py

@ -0,0 +1,35 @@
#!/usr/bin/python3
# -*- coding:utf-8 -*-
import os, re
workDir = os.path.split(os.path.realpath(__file__))[0]
domainList = os.popen('sh ' + workDir + '/source.sh | sort -u').read().split('\n')
regex = r'^(?=^.{3,255}$)[a-zA-Z0-9][a-zA-Z0-9\-]{0,62}(.[a-zA-Z0-9][a-zA-Z0-9\-]{0,62})+$'
for domain in domainList:
if re.search(regex, domain) is None:
domainList.remove(domain)
with open (workDir + '/../chinalist.txt', 'w') as fileObj:
fileObj.write('\n'.join(domainList) + '\n')
os.popen('gzip -cf9 ' + workDir + '/../chinalist.txt > ' + workDir + '/../chinalist.txt.gz')
from IPy import IP, IPSet
ipv4List = IPSet()
ipv6List = IPSet()
ipList = os.popen('sh ' + workDir + '/source-ip.sh | sort -u').read().split('\n')
for ipStr in ipList:
try:
ipAddr = IP(ipStr)
if ipAddr.version() == 4:
ipv4List.add(ipAddr)
else:
ipv6List.add(ipAddr)
except:
pass
ipList = []
for ipAddr in ipv4List:
ipList.append(str(ipAddr))
for ipAddr in ipv6List:
ipList.append(str(ipAddr))
with open (workDir + '/../china-ip.txt', 'w') as fileObj:
fileObj.write('\n'.join(ipList) + '\n')
os.popen('gzip -cf9 ' + workDir + '/../china-ip.txt > ' + workDir + '/../china-ip.txt.gz')

20
asset/chinalist/build/source-ip.sh

@ -0,0 +1,20 @@
curl -sL https://github.com/17mon/china_ip_list/raw/master/china_ip_list.txt
curl -sL https://github.com/misakaio/chnroutes2/raw/master/chnroutes.txt | sed '/^#/d'
curl -sL https://gaoyifan.github.io/china-operator-ip/cernet.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/china.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/chinanet.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/cmcc.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/cstnet.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/drpeng.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/googlecn.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/tietong.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/unicom.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/cernet6.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/china6.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/chinanet6.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/cmcc6.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/cstnet6.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/drpeng6.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/googlecn6.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/tietong6.txt
curl -sL https://gaoyifan.github.io/china-operator-ip/unicom6.txt

2
asset/chinalist/build/source.sh

@ -0,0 +1,2 @@
curl -sL https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf | sed 's/server=\///g;s/\/114.114.114.114//g' | sort -u
curl -sL https://raw.githubusercontent.com/hq450/fancyss/master/rules/WhiteList_new.txt | sed 's/Server=\///g;s/\///g' | sort -u

13
asset/gfwlist/build/build.py

@ -0,0 +1,13 @@
#!/usr/bin/python3
# -*- coding:utf-8 -*-
import os, re
workDir = os.path.split(os.path.realpath(__file__))[0]
domainList = os.popen('sh ' + workDir + '/source.sh | sort -u').read().split('\n')
regex = r'^(?=^.{3,255}$)[a-zA-Z0-9][a-zA-Z0-9\-]{0,62}(.[a-zA-Z0-9][a-zA-Z0-9\-]{0,62})+$'
for domain in domainList:
if re.search(regex, domain) is None:
domainList.remove(domain)
with open (workDir + '/../gfwlist.txt', 'w') as fileObj:
fileObj.write('\n'.join(domainList) + '\n')
os.popen('gzip -cf9 ' + workDir + '/../gfwlist.txt > ' + workDir + '/../gfwlist.txt.gz')

7
asset/gfwlist/build/source.sh

@ -0,0 +1,7 @@
curl -sL https://raw.githubusercontent.com/Loukky/gfwlist-by-loukky/master/gfwlist.txt | base64 -d | sort -u | sed '/^$\|@@/d'| sed 's#!.\+##; s#|##g; s#@##g; s#http:\/\/##; s#https:\/\/##;' | sed '/\*/d; /apple\.com/d; /sina\.cn/d; /sina\.com\.cn/d; /baidu\.com/d; /qq\.com/d' | sed '/^[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+$/d' | grep '^[0-9a-zA-Z\.-]\+$' | grep '\.' | sed 's#^\.\+##' | sort -u
curl -sL https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt | base64 -d | sort -u | sed '/^$\|@@/d'| sed 's#!.\+##; s#|##g; s#@##g; s#http:\/\/##; s#https:\/\/##;' | sed '/\*/d; /apple\.com/d; /sina\.cn/d; /sina\.com\.cn/d; /baidu\.com/d; /qq\.com/d' | sed '/^[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+$/d' | grep '^[0-9a-zA-Z\.-]\+$' | grep '\.' | sed 's#^\.\+##' | sort -u
curl -sL https://github.com/Loyalsoldier/v2ray-rules-dat/releases/download/$(curl -sL https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')/gfw.txt | sort -u
curl -sL https://raw.githubusercontent.com/hq450/fancyss/master/rules/gfwlist.conf | sed 's/ipset=\/\.//g; s/\/gfwlist//g; /^server/d' | sort -u
Loading…
Cancel
Save