-
Notifications
You must be signed in to change notification settings - Fork 19
/
update.py
131 lines (95 loc) · 3.81 KB
/
update.py
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import os
import urllib.request
import glob
import zipfile
print('update from github...')
print('download hxcrypto')
urllib.request.urlretrieve('https://github.com/v3aqb/hxcrypto/archive/master.zip', 'org.zip')
flist = glob.glob('fwlite/hxcrypto/*.*')
for f in flist:
os.remove(f)
with zipfile.ZipFile('org.zip') as z:
namelist = z.namelist()
namelist = [name for name in namelist if '/hxcrypto/' in name]
namelist = [name for name in namelist if not name.endswith('/')]
for name in namelist:
if 'ctypes_libsodium' in name:
continue
data = z.open(name).read()
_to = name.replace('hxcrypto-master/', 'fwlite/')
print(_to)
with open(_to, 'wb') as f:
f.write(data)
os.remove('org.zip')
print('download fwlite-cli')
urllib.request.urlretrieve('https://github.com/v3aqb/fwlite-cli/archive/master.zip', 'org.zip')
flist = glob.glob('fwlite/fwlite_cli/*.py')
for f in flist:
os.remove(f)
with zipfile.ZipFile('org.zip') as z:
namelist = z.namelist()
namelist = [name for name in namelist if '/fwlite_cli/' in name]
namelist = [name for name in namelist if '.py' in name]
for name in namelist:
data = z.open(name).read()
_to = name.replace('fwlite-cli-master/', 'fwlite/')
print(_to)
with open(_to, 'wb') as f:
f.write(data)
os.remove('org.zip')
print('download fwlite-gui')
urllib.request.urlretrieve('https://github.com/v3aqb/fwlite-gui/archive/master.zip', 'org.zip')
flist = glob.glob('fwlite/fwlite_gui/*.py')
for f in flist:
os.remove(f)
with zipfile.ZipFile('org.zip') as z:
namelist = z.namelist()
namelist = [name for name in namelist if '/fwlite_gui/' in name]
namelist = [name for name in namelist if not name.endswith('/')]
for name in namelist:
data = z.open(name).read()
_to = name.replace('fwlite-gui-master/', 'fwlite/')
print(_to)
with open(_to, 'wb') as f:
f.write(data)
os.remove('org.zip')
print('download hxsocks')
urllib.request.urlretrieve('https://github.com/v3aqb/hxsocks/archive/master.zip', 'org.zip')
if not os.path.isdir('fwlite/hxsocks'):
if os.path.exists('fwlite/hxsocks'):
os.remove('fwlite/hxsocks')
os.mkdir('fwlite/hxsocks')
flist = glob.glob('fwlite/hxsocks/*.py')
for f in flist:
os.remove(f)
with zipfile.ZipFile('org.zip') as z:
namelist = z.namelist()
namelist = [name for name in namelist if '/hxsocks/' in name]
namelist = [name for name in namelist if not name.endswith('/')]
for name in namelist:
data = z.open(name).read()
_to = name.replace('hxsocks-master/', 'fwlite/')
print(_to)
with open(_to, 'wb') as f:
f.write(data)
os.remove('org.zip')
print('download gfwlist.txt')
urllib.request.urlretrieve('https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt', './conf/gfwlist.txt')
with open('./conf/gfwlist.txt') as f:
data = f.read()
if '!' not in data:
import base64
data = ''.join(data.split())
data = base64.b64decode(data).decode()
with open('./conf/gfwlist.txt', 'w') as f:
f.write(data)
print('download china_ip_list.txt')
urllib.request.urlretrieve('https://github.com/QiuSimons/Chnroute/raw/master/dist/chnroute/chnroute.txt', './conf/china_ip_list.txt')
print('download china_ip_list_v6.txt')
urllib.request.urlretrieve('https://github.com/QiuSimons/Chnroute/raw/master/dist/chnroute/chnroute-v6.txt', './conf/china_ip_list_v6.txt')
print('download adblock.txt')
urllib.request.urlretrieve('https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts', './conf/adblock.txt')
print('download chinalist.txt')
urllib.request.urlretrieve('https://github.com/QiuSimons/Chnroute/raw/master/dist/chnroute/chinalist.txt', './conf/chinalist.txt')
print('completed.')
input()