-
Notifications
You must be signed in to change notification settings - Fork 0
/
colo.py
34 lines (27 loc) · 831 Bytes
/
colo.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
#Collect from https://luotianyi.vc/3258.html
import requests, threading, queue
IPQueue = queue.Queue()
_WORKER_THREAD_NUM = 3
class Workers(threading.Thread):
def run(self):
while not IPQueue.empty():
ip = IPQueue.get()
try:
rsp = requests.head('http://' + ip, timeout=2).headers
print(ip, rsp['CF-RAY'])
except:
pass
def main():
global IPQueue
with open('colo-data.txt', 'r') as f:
for ip in f.read().splitlines():
IPQueue.put(ip)
threads = []
for i in range(_WORKER_THREAD_NUM) :
thread = Workers()
thread.start()
threads.append(thread)
for thread in threads :
thread.join()
if __name__ == '__main__':
main()