From dc112c5d1ef37f46991dc983aa7ca1f875d76ba0 Mon Sep 17 00:00:00 2001 From: Error063 Date: Sun, 12 May 2024 03:24:30 +0800 Subject: [PATCH] =?UTF-8?q?add=20support=20for=20Maimai=20DX=20CN=202023?= =?UTF-8?q?=20(=E8=88=9E=E8=90=8CDX=202023),=20add=20support=20for=20wecha?= =?UTF-8?q?t=20aime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/allnet.py | 74 +++++++++++--------------------------------------- 1 file changed, 16 insertions(+), 58 deletions(-) diff --git a/core/allnet.py b/core/allnet.py index 2e4c9ad..5589250 100644 --- a/core/allnet.py +++ b/core/allnet.py @@ -1,27 +1,26 @@ -import hashlib -from typing import Dict, List, Any, Optional, Tuple, Union, Final -import logging, coloredlogs -from logging.handlers import TimedRotatingFileHandler -from twisted.web.http import Request -from datetime import datetime -import pytz import base64 -import zlib +import coloredlogs import json -from enum import Enum -from Crypto.PublicKey import RSA -from Crypto.Hash import SHA -from Crypto.Signature import PKCS1_v1_5 -from time import strptime -from os import path -import urllib.parse +import logging import math +import urllib.parse +import zlib +from datetime import datetime +from logging.handlers import TimedRotatingFileHandler +from os import path +from typing import Dict, List, Any, Optional, Union, Final + +import pytz +from Crypto.Hash import SHA +from Crypto.PublicKey import RSA +from Crypto.Signature import PKCS1_v1_5 +from twisted.web.http import Request from .config import CoreConfig -from .utils import Utils -from .data import Data from .const import * +from .data import Data from .title import TitleServlet +from .utils import Utils BILLING_DT_FORMAT: Final[str] = "%Y%m%d%H%M%S" @@ -513,47 +512,6 @@ class AllnetServlet: self.logger.info(f"Ping from {Utils.get_ip_addr(request)}") return b"naomi ok" - # def handle_qr_alive(self, request: Request, _: Dict): - # return b"alive" - # - # def handle_qr_lookup(self, request: Request, _: Dict) -> bytes: - # req = json.loads(request.content.getvalue()) - # access_code = req["qrCode"][-20:] - # timestamp = req["timestamp"] - # - # try: - # userId = self.chimedb.handle_lookup(access_code) - # data = json.dumps({ - # "userID": userId, - # "errorID": 0, - # "timestamp": timestamp, - # "key": self.hash_data(userId, timestamp) - # }) - # except Exception as e: - # - # self.logger.error(e.with_traceback(None)) - # - # data = json.dumps({ - # "userID": -1, - # "errorID": 1, - # "timestamp": timestamp, - # "key": self.hash_data(-1, timestamp) - # }) - # - # self.logger.info(data) - # return data.encode() - # - # - # def hash_data(self, chip_id, timestamp): - # input_string = f"{chip_id}{timestamp}XcW5FW4cPArBXEk4vzKz3CIrMuA5EVVW" - # hash_object = hashlib.sha256(input_string.encode('utf-8')) - # hex_dig = hash_object.hexdigest() - # - # formatted_hex = format(int(hex_dig, 16), '064x').upper() - # - # return formatted_hex - - def billing_req_to_dict(self, data: bytes): """ Parses an billing request string into a python dictionary