From 2c6069a9132e9e36ca60b757f317abf05601872a Mon Sep 17 00:00:00 2001 From: "Autumn.home" Date: Sat, 20 Jul 2024 17:23:44 +0800 Subject: [PATCH] update init db --- core/db.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/db.py b/core/db.py index d0ac467..fa643c6 100644 --- a/core/db.py +++ b/core/db.py @@ -4,7 +4,7 @@ # @version: import time from urllib.parse import quote_plus - +from motor.motor_asyncio import AsyncIOMotorGridFSBucket from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorCursor from core.default import * from core.config import * @@ -82,6 +82,19 @@ async def create_database(): # dirDict = get_dirDict() # await collection.insert_one( # {"name": "DirDic", 'value': dirDict, 'type': 'dirDict'}) + # 目录扫描字典 + fs = AsyncIOMotorGridFSBucket(client) + content = get_dirDict() + if content: + byte_content = content.encode('utf-8') + await fs.upload_from_stream('dirdict', byte_content) + # 子域名字典 + content = get_domainDict() + if content: + byte_content = content.encode('utf-8') + await fs.upload_from_stream('DomainDic', byte_content) + logger.info("Document DomainDic uploaded to GridFS.") + await collection.insert_one( {"name": "notification", 'dirScanNotification': True, 'portScanNotification': True, 'sensitiveNotification': True,