Skip to content

Commit 7cb8b07

Browse files
committed
只保留gogotester的部分IP列表,优化随机IP逻辑,ip_tmpok.txt保留查询成功的IP列表,方便下次查询时跳过非gae可用的IP
1 parent 6bd6a91 commit 7cb8b07

File tree

3 files changed

+207
-2877
lines changed

3 files changed

+207
-2877
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ checkgoogleip
2525
* 默认会尝试使用gevent及内置的ssl库查询,好处:明显优化cpu及内存使用,最大线程数量限制了128条,可以支持pyOpenSSL库,但需要设置g_usegevent为0
2626
* 默认增加一些IP段检查,并且只随机检查700个IP
2727
* 默认会保存测试IP的结果到ip_tmperror.txt(失败)与ip_tmpok.txt(成功),下次运行脚本时会预先读取,并会跳过这些IP的查询,如果不想保留ip_tmperror.txt,则g_autodeltmperrorfile为1,如果不想保留ip_tmpok.txt,则需要设置g_autodeltmpokfile=1,如果程序正常运行结束,则会检查g_autodeltmperrorfile及g_autodeltmpokfile,并执行对应的操作,如果程序运行异常,需要关闭程序,则会保留这两个文件
28-
* 增加gogotest里面的IP列表,特别感谢该开发者提供的IP列表
28+
* 增加gogotest里面的部分IP列表,特别感谢该开发者
2929

3030
使用方法
3131
-------------

checkip.py

Lines changed: 206 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,175 @@
8686
64.18.0.0/20
8787
207.126.144.0/20
8888
173.194.0.0/16
89+
1.179.248.0-255
90+
106.162.192.148-187
91+
108.166.34.0-255
92+
118.174.24.0-255
93+
118.174.25.0-255
94+
118.174.26.0-255
95+
118.174.27.0-255
96+
121.195.178.0-255
97+
121.78.74.68-123
98+
123.205.250.0-255
99+
123.205.251.68-123
100+
124.160.89.0-255
101+
130.211.115.0-255
102+
130.211.76.0-255
103+
130.211.78.0-255
104+
130.211.82.0-255
105+
146.148.16.0-255
106+
146.148.24.0-255
107+
146.148.34.0-255
108+
146.148.8.0-255
109+
146.148.9.0-255
110+
173.194.0.0-255
111+
173.194.1.0-255
112+
173.194.10.0-255
113+
173.194.11.0-255
114+
173.194.12.0-255
115+
173.194.120.0-255
116+
173.194.121.0-255
117+
173.194.122.0-255
118+
173.194.123.0-255
119+
173.194.124.0-255
120+
173.194.125.0-255
121+
173.194.126.0-255
122+
173.194.127.0-255
123+
173.194.128.0-255
124+
173.194.129.0-255
125+
173.194.13.0-255
126+
173.194.130.0-255
127+
173.194.131.0-255
128+
173.194.132.0-255
129+
173.194.133.0-255
130+
173.194.134.0-255
131+
173.194.135.0-255
132+
173.194.136.0-255
133+
173.194.137.0-255
134+
173.194.138.0-255
135+
173.194.139.0-255
136+
173.194.14.0-255
137+
173.194.140.0-255
138+
173.194.141.0-255
139+
173.194.142.0-255
140+
173.194.143.0-255
141+
173.194.162.0-255
142+
173.194.166.0-255
143+
173.194.174.0-255
144+
173.194.193.0-255
145+
173.194.196.0-255
146+
173.194.198.0-255
147+
173.194.201.0-255
148+
173.194.202.0-255
149+
173.194.203.0-255
150+
173.194.205.0-255
151+
173.194.206.0-255
152+
173.194.207.0-255
153+
173.194.208.0-255
154+
173.194.209.0-255
155+
173.194.21.0-255
156+
173.194.212.0-255
157+
173.194.214.0-255
158+
173.194.22.0-255
159+
173.194.220.0-255
160+
173.194.221.0-255
161+
173.194.222.0-255
162+
173.194.223.0-255
163+
173.194.224.0-255
164+
173.194.225.0-255
165+
173.194.226.0-255
166+
173.194.227.0-255
167+
173.194.228.0-255
168+
173.194.229.0-255
169+
173.194.23.0-255
170+
173.194.230.0-255
171+
173.194.231.0-255
172+
173.194.232.0-255
173+
173.194.233.0-255
174+
173.194.234.0-255
175+
173.194.24.0-255
176+
173.194.25.0-255
177+
173.194.26.0-255
178+
173.194.34.0-255
179+
173.194.6.0-255
180+
173.194.64.0-255
181+
173.194.65.0-255
182+
173.194.66.0-255
183+
173.194.67.0-255
184+
173.194.69.0-255
185+
173.194.7.0-255
186+
173.194.70.0-255
187+
173.194.71.0-255
188+
173.194.73.0-255
189+
173.194.74.0-255
190+
173.194.77.0-255
191+
173.194.78.0-255
192+
173.194.79.0-255
193+
173.194.9.0-255
194+
178.60.128.1-63
195+
193.120.166.64-127
196+
193.92.133.0-63
197+
194.78.20.16-31
198+
194.78.99.0-255
199+
195.249.20.192-255
200+
202.106.93.0-255
201+
202.39.143.1-123
202+
202.69.26.0-255
203+
203.66.124.129-251
204+
208.117.224.0-255
205+
208.117.225.0-255
206+
208.117.226.0-255
207+
208.117.227.0-255
208+
208.117.228.0-255
209+
208.117.229.0-255
210+
208.117.230.0-255
211+
208.117.231.0-255
212+
208.117.232.0-255
213+
208.117.236.0-255
214+
208.117.238.0-255
215+
208.117.239.0-255
216+
208.117.240.0-255
217+
208.117.242.0-255
218+
208.117.248.0-255
219+
208.117.250.0-255
220+
208.117.251.0-255
221+
208.117.254.0-255
222+
208.117.255.0-255
223+
209.85.228.0-255
224+
210.242.125.20-59
225+
212.188.15.0-255
226+
213.186.229.0-63
227+
213.240.44.0-31
228+
218.176.242.0-255
229+
24.156.131.0-255
230+
41.206.96.0-255
231+
62.116.207.0-63
232+
62.197.198.193-251
233+
64.15.112.0-255
234+
64.15.113.0-255
235+
64.15.114.0-255
236+
64.15.115.0-255
237+
64.15.117.0-255
238+
64.15.119.0-255
239+
64.15.120.0-255
240+
64.15.124.0-255
241+
64.15.126.0-255
242+
64.233.160.0-255
243+
64.233.168.0-255
244+
64.233.171.0-255
245+
66.102.133.0-255
246+
66.102.136.0-255
247+
66.102.255.0-255
248+
80.228.65.128-191
249+
81.175.29.128-191
250+
84.235.77.0-255
251+
85.182.250.0-255
252+
86.127.118.128-191
253+
93.183.211.192-255
254+
93.94.217.0-31
255+
93.94.218.0-31
256+
94.200.103.64-71
257+
94.40.70.0-63
89258
'''
90259

91260

@@ -115,9 +284,9 @@
115284
g_excludessdomain=()
116285

117286

118-
"是否自动删除记录查询成功的IP文件,0为不删除,1为删除"
287+
"是否自动删除记录查询成功的非google的IP文件,方便下次跳过连接,0为不删除,1为删除"
119288
"文件名:ip_tmpok.txt,格式:ip 连接与握手时间 ssl域名"
120-
g_autodeltmpokfile = 1
289+
g_autodeltmpokfile = 0
121290
"是否自动删除记录查询失败的IP文件,0为不删除,1为删除"
122291
"ip_tmperror.txt,格式:ip"
123292
g_autodeltmperrorfile = 0
@@ -265,9 +434,8 @@ def loadLastResult(self):
265434
gwsname = ""
266435
if len(ips) > 3:
267436
gwsname = ips[3]
268-
okresult.add(from_string(ips[0]))
269-
if checkvalidssldomain(ips[2],gwsname):
270-
self.okqueue.put((int(ips[1]),ips[0],ips[2],gwsname))
437+
if not checkvalidssldomain(ips[2],gwsname):
438+
okresult.add(from_string(ips[0]))
271439
if os.path.exists(g_tmperrorfile):
272440
with open(g_tmperrorfile,"r") as fd:
273441
for line in fd:
@@ -465,11 +633,17 @@ def getgooglesvrname(self,conn,sock,ip):
465633
except SSLError as e:
466634
sleep(0.5)
467635
continue
636+
readlen = len(d)
637+
if readlen == 0:
638+
sleep(0.5)
639+
continue
468640
data = data + d.replace("\r","")
469641
index = data.find("\n\n")
470642
if index != -1:
471643
gwsname = getgooglesvrnamefromheader(data[0:index])
472644
return gwsname
645+
elif readlen <= 64:
646+
sleep(0.01)
473647
return ""
474648
except Exception as e:
475649
info = "%s" % e
@@ -572,58 +746,72 @@ def ramdomip(self):
572746
continue
573747
nbegin = from_string(begin)
574748
nend = from_string(end)
575-
iplinelist.append([nbegin,nend,nend - nbegin + 1])
749+
iplinelist.append([nbegin,nend])
576750

577751
hadIPData = True
578752
putdata = False
579-
putipcnt = 0
580753
while hadIPData:
581754
if evt_ipramdomend.is_set():
582755
break
583756
hadIPData = False
757+
index = -1
758+
emptyindexlist=[]
759+
#PRINT("ramdom ip array: % d" % len(iplinelist))
584760
for itemlist in iplinelist:
585761
begin = itemlist[0]
586762
end = itemlist[1]
587-
itemlen = itemlist[2]
763+
itemlen = end - begin + 1
764+
index += 1
588765
if itemlen <= 0:
589766
continue
590767
if self.cacheResult.queryfinish():
591768
break
592-
if itemlen > 1000:
769+
'''if itemlen > 1000:
593770
itemlen = 10
594771
elif itemlen > 5:
595772
itemlen = 5
773+
'''
596774
if itemlen <= 2:
597775
selectcnt = itemlen
598776
else:
599-
selectcnt = random.randint(2,itemlen)
777+
selectcnt = 2
600778
for i in xrange(0,selectcnt):
601779
k = random.randint(begin,end)
602780
first = True
603781
findOK = True
782+
checkcnt = 0
783+
checkend = k
784+
# try get next index in circle
604785
while k in cacheip:
786+
checkcnt += 1
605787
if k < end:
606788
k += 1
607-
elif not first:
608-
findOK = False
609-
break
610789
else:
611-
first = False
612790
k = begin
791+
# if met itself,nee break
792+
if k == checkend :
793+
findOK = False
794+
break
795+
#if checkcnt > 1:
796+
# PRINT("[%d]total cnt: %d,index:%d,ramdom checkcnt:%d,found:%d" % (index,itemlen,checkend-begin,checkcnt,findOK))
613797
if findOK:
614798
hadIPData = True
615799
self.ipqueue.put(k)
616800
cacheip.add(k)
617-
putipcnt += 1
618801
if not putdata:
619802
evt_ipramdomstart.set()
620803
putdata = True
621804
if evt_ipramdomend.is_set():
622805
break
623-
itemlist[2] -= i + 1
624-
if putipcnt >= 500:
806+
# not found,no need to ramdom next index
807+
if not findOK:
808+
emptyindexlist.insert(0,index)
809+
break
810+
if self.ipqueue.qsize() >= 500:
625811
sleep(1)
626-
putipcnt = 0
812+
for empytindex in emptyindexlist:
813+
iplinelist.pop(empytindex)
814+
#PRINT("remote index: %d" % empytindex )
627815
if not evt_ipramdomstart.is_set():
628816
evt_ipramdomstart.set()
629817

0 commit comments

Comments
 (0)