2024-04-26 10:41:02 +00:00
|
|
|
from loguru import logger
|
2024-01-31 00:48:20 +00:00
|
|
|
import pickledb
|
2024-03-27 16:49:52 +00:00
|
|
|
from multiprocessing import Value
|
2024-01-31 00:48:20 +00:00
|
|
|
from contextvars import ContextVar
|
|
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
|
|
import redis.asyncio as redis
|
|
|
|
|
from xkcdpass import xkcd_password as xp
|
|
|
|
|
|
|
|
|
|
from server.utils.loguru_handler import InterceptHandler
|
2024-06-22 07:22:11 +00:00
|
|
|
from server.utils.logger import configure_logger
|
2024-04-26 10:41:02 +00:00
|
|
|
from database_lib import SQLiteCacheBackend
|
2024-01-31 00:48:20 +00:00
|
|
|
|
2024-06-22 07:22:11 +00:00
|
|
|
# logging.basicConfig(handlers=[InterceptHandler()], level=0, force=True)
|
|
|
|
|
configure_logger()
|
|
|
|
|
|
2024-04-26 10:41:02 +00:00
|
|
|
medium_cache = SQLiteCacheBackend('medium_db_cache.sqlite')
|
|
|
|
|
medium_cache.init_db()
|
|
|
|
|
medium_cache.enable_zstd()
|
2024-06-22 07:22:11 +00:00
|
|
|
|
2024-04-26 10:41:02 +00:00
|
|
|
logger.debug(f"Database length: {medium_cache.all_length()}")
|
2024-01-31 00:48:20 +00:00
|
|
|
|
2024-04-26 10:41:02 +00:00
|
|
|
redis_storage = redis.Redis(host="dragonfly", port=6379, db=0)
|
2024-01-31 00:48:20 +00:00
|
|
|
|
|
|
|
|
url_correlation: ContextVar[Optional[str]] = ContextVar("url_correlation", default="UNKNOWN_URL")
|
|
|
|
|
transponder_code_correlation: ContextVar[Optional[str]] = ContextVar("transponder_code_correlation", default="unknown transponder location... Beep!")
|
|
|
|
|
|
2024-02-07 13:36:46 +00:00
|
|
|
home_page_process = {}
|
|
|
|
|
|
2024-01-31 00:48:20 +00:00
|
|
|
ban_db = pickledb.load('ban_post_list.db', True)
|
|
|
|
|
|
|
|
|
|
WORDS_LIST_FILE = "xkcdpass/static/legac"
|
|
|
|
|
|
2024-03-18 18:33:34 +00:00
|
|
|
xkcd_passwd = xp.generate_wordlist(wordfile=WORDS_LIST_FILE, min_length=5, max_length=8)
|
|
|
|
|
|
2024-06-22 07:22:11 +00:00
|
|
|
maintenance_mode = Value('b', False)
|