使用uvloop加速子域请求

This commit is contained in:
Jing Ling
2020-04-28 21:47:17 +08:00
parent 99af838fcb
commit 2fd767fb6f
2 changed files with 15 additions and 0 deletions
+10
View File
@@ -227,6 +227,15 @@ async def bulk_request(data, port):
return to_req_data + no_req_data return to_req_data + no_req_data
def set_loop_policy():
try:
import uvloop
except ImportError:
pass
else:
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
def run_request(domain, data, port): def run_request(domain, data, port):
""" """
调用子域请求入口函数 调用子域请求入口函数
@@ -238,6 +247,7 @@ def run_request(domain, data, port):
:rtype: list :rtype: list
""" """
logger.log('INFOR', f'开始执行子域请求模块') logger.log('INFOR', f'开始执行子域请求模块')
set_loop_policy()
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
asyncio.set_event_loop(loop) asyncio.set_event_loop(loop)
data = utils.set_id_none(data) data = utils.set_id_none(data)
+5
View File
@@ -519,6 +519,11 @@ def check_pre():
if version < '3.8': if version < '3.8':
logger.log('FATAL', 'OneForAll在Windows系统运行时需要Python 3.8以上版本') logger.log('FATAL', 'OneForAll在Windows系统运行时需要Python 3.8以上版本')
exit(1) exit(1)
if system in {"Linux", "Darwin"}:
try:
import uvloop
except ImportError:
logger.log('ALERT', f'请手动安装uvloop的Python库加速子域请求')
def check_env(): def check_env():