-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstratum_check.py
39 lines (28 loc) · 983 Bytes
/
stratum_check.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
#!/usr/bin/env python
import sys
import json
from stratum_scanner import stratum_scan
import datetime
now = datetime.datetime.now().replace(microsecond=0)
def main():
if len(sys.argv) != 2:
print("Usage: python stratum_check.py stratum_list.json")
sys.exit()
else:
with open(sys.argv[1], 'r') as stratum_file:
stratum_dict = json.load(stratum_file)
result=stratum_check(stratum_dict)
def stratum_check(stratum_dict):
scan_result = {'stratum':[]}
for stratum in stratum_dict['stratum']:
result = stratum_scan(stratum['host'],stratum['port'])
if result == False or result == {}:
continue
else:
stratum['result']=result
scan_result['stratum'].append(stratum)
with open("./stratum_live/test.json", 'w') as data_file:
data_file.write(json.dumps(scan_result, indent=4))
if __name__ == "__main__":
# execute only if run as a script
main()