迁移到 rapidjson,增加 ssl 验证功能,其他改进
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# 舞萌DX 2024
|
||||
# 舞萌DX
|
||||
# 标题服务器通讯实现
|
||||
|
||||
import zlib
|
||||
@@ -11,8 +11,10 @@ from ctypes import c_int32
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Util.Padding import unpad
|
||||
from Config import *
|
||||
import certifi
|
||||
|
||||
# 舞萌DX 2024
|
||||
# omg it's leaking
|
||||
AesKey = "n7bx6:@Fg_:2;5E89Phy7AyIcpxEQ:R@"
|
||||
AesIV = ";;KjR1C3hgB1ovXa"
|
||||
ObfuscateParam = "BEs2D5vW"
|
||||
@@ -57,6 +59,8 @@ class AES_PKCS7(object):
|
||||
return text + padding_text
|
||||
|
||||
def getSDGBApiHash(api):
|
||||
# API 的 Hash 的生成
|
||||
# 有空做一下 Hash 的彩虹表?
|
||||
return hashlib.md5((api+"MaimaiChn"+ObfuscateParam).encode()).hexdigest()
|
||||
|
||||
def apiSDGB(data:str, targetApi:str, userAgentExtraData:str, noLog:bool=False, timeout:int=5):
|
||||
@@ -91,7 +95,7 @@ def apiSDGB(data:str, targetApi:str, userAgentExtraData:str, noLog:bool=False, t
|
||||
"Expect": "100-continue"
|
||||
},
|
||||
content=reqData_deflated,
|
||||
verify=False,
|
||||
verify=certifi.where(),
|
||||
timeout=timeout
|
||||
)
|
||||
if not noLog:
|
||||
@@ -129,16 +133,16 @@ def apiSDGB(data:str, targetApi:str, userAgentExtraData:str, noLog:bool=False, t
|
||||
raise SDGBRequestError("请求格式错误")
|
||||
except SDGBResponseError as e:
|
||||
# 响应解析错误,重试但是只一次
|
||||
logger.warning(f"Will now retry. {e}")
|
||||
logger.warning(f"将重试一次 Resp Err: {e}")
|
||||
retries += 2
|
||||
time.sleep(2)
|
||||
except Exception as e:
|
||||
# 其他错误,重试
|
||||
logger.warning(f"Will now retry. {e}")
|
||||
logger.warning(f"将开始重试请求. {e}")
|
||||
retries += 1
|
||||
time.sleep(2)
|
||||
|
||||
raise SDGBApiError("Multiple retries failed to make a successful request")
|
||||
raise SDGBApiError("重试多次仍然无法成功请求服务器")
|
||||
|
||||
def calcSpecialNumber():
|
||||
"""使用 c_int32 实现的 SpecialNumber 算法"""
|
||||
|
||||
Reference in New Issue
Block a user