mirror of
https://github.com/0-8-4/miui-auto-tasks.git
synced 2025-01-30 15:08:53 +00:00
fix: 修复docker编译失败,jsonpath为空时报错 (#315)
* 🔧 自动更新requirements * feat: 更改geetest验证方式 * 🔧 自动更新requirements * Update Dockerfile * Update requirements.txt * 🔧 自动更新requirements * Update requirements.txt * Update Dockerfile * Update docker-image.yml * Update Dockerfile * 🔧 自动更新requirements * feat: geetest添加自定义返回参数 * feat: geetest添加自定义返回参数 * Update pyproject.toml * Update Dockerfile * fix: 修复docker编译失败,jsonpath为空时报错 * chore: config添加默认值 * ci: 自动更改版本号 * ci: 自动更新版本号 * 🔧 自动更新requirements * fix: 补全dockerfile缺失 * ci: 拉取本地仓库 * ci: 添加其他docker 设备 * ci: 改用docker更改版本号 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
88f2c77633
commit
e2b4643b4f
@ -8,7 +8,9 @@ WORKDIR /srv
|
||||
|
||||
COPY ./utils ./utils
|
||||
|
||||
COPY ./pyproject.toml ./miuitask.py ./docker_start.sh ./
|
||||
RUN echo "VERSION='$(git describe --tags --abbrev=0)'" > ./utils/__version__.py
|
||||
|
||||
COPY ./pyproject.toml ./pdm.lock ./miuitask.py ./docker_start.sh ./
|
||||
|
||||
RUN pdm install --prod && \
|
||||
echo '0 4 * * * /bin/sh -c "sleep $((RANDOM % 1800 + 1)); cd /srv && pdm run /srv/miuitask.py"' > /var/spool/cron/crontabs/root && \
|
||||
|
@ -1,12 +1,12 @@
|
||||
[project]
|
||||
name = ""
|
||||
version = ""
|
||||
name = "miui-auto-tasks"
|
||||
version = "1.0.0"
|
||||
description = ""
|
||||
authors = []
|
||||
dependencies = [
|
||||
"loguru>=0.7.2",
|
||||
"httpx>=0.25.1",
|
||||
"cryptography==44.0.0",
|
||||
"pycryptodome>=3.21.0",
|
||||
"pyyaml>=6.0.1",
|
||||
"tenacity>=8.2.3",
|
||||
"tzdata>=2023.3",
|
||||
|
@ -1,7 +1,7 @@
|
||||
cryptography==44.0.0
|
||||
jsonpath_ng==1.7.0
|
||||
loguru==0.7.3
|
||||
onepush==1.4.0
|
||||
pycryptodome==3.21.0
|
||||
PyYAML==6.0.2
|
||||
qrcode==8.0
|
||||
Requests==2.32.3
|
||||
|
4
utils/__version__.py
Normal file
4
utils/__version__.py
Normal file
@ -0,0 +1,4 @@
|
||||
"""
|
||||
版本记录文件
|
||||
"""
|
||||
VERSION = "DEBUG"
|
@ -1,13 +1,15 @@
|
||||
"""
|
||||
Date: 2023-11-13 19:55:22
|
||||
LastEditors: Night-stars-1 nujj1042633805@gmail.com
|
||||
LastEditTime: 2025-01-24 22:02:00
|
||||
LastEditTime: 2025-01-25 21:27:29
|
||||
"""
|
||||
|
||||
import json
|
||||
import time
|
||||
from traceback import print_exc
|
||||
|
||||
from jsonpath_ng import parse
|
||||
from jsonpath_ng.exceptions import JsonPathParserError
|
||||
|
||||
from .config import ConfigManager
|
||||
from .data_model import GeetestResult
|
||||
@ -99,18 +101,21 @@ def get_validate(
|
||||
)
|
||||
log.debug(response.text)
|
||||
result = response.json()
|
||||
geetest_validate_expr = parse(_conf.preference.geetest_validate_path)
|
||||
geetest_validate_match = geetest_validate_expr.find(result)
|
||||
if len(geetest_validate_match) > 0:
|
||||
validate = geetest_validate_match[0].value
|
||||
geetest_challenge_expr = parse(_conf.preference.geetest_challenge_path)
|
||||
geetest_challenge_match = geetest_challenge_expr.find(result)
|
||||
if len(geetest_challenge_match) > 0:
|
||||
challenge = geetest_challenge_match[0].value
|
||||
geetest_result_expr = parse(_conf.preference.geetest_result_path)
|
||||
geetest_result_match = geetest_result_expr.find(result)
|
||||
if len(geetest_result_match) > 0:
|
||||
result = geetest_result_match[0].value
|
||||
try:
|
||||
geetest_validate_expr = parse(_conf.preference.geetest_validate_path)
|
||||
geetest_validate_match = geetest_validate_expr.find(result)
|
||||
if len(geetest_validate_match) > 0:
|
||||
validate = geetest_validate_match[0].value
|
||||
geetest_challenge_expr = parse(_conf.preference.geetest_challenge_path)
|
||||
geetest_challenge_match = geetest_challenge_expr.find(result)
|
||||
if len(geetest_challenge_match) > 0:
|
||||
challenge = geetest_challenge_match[0].value
|
||||
geetest_result_expr = parse(_conf.preference.geetest_result_path)
|
||||
geetest_result_match = geetest_result_expr.find(result)
|
||||
if len(geetest_result_match) > 0:
|
||||
result = geetest_result_match[0].value
|
||||
except JsonPathParserError:
|
||||
print_exc()
|
||||
if validate and challenge:
|
||||
return GeetestResult(challenge=challenge, validate=validate)
|
||||
else:
|
||||
|
@ -148,13 +148,13 @@ class Preference:
|
||||
geetest_data: Optional[dict] = None,
|
||||
geetest_validate_path="$.data.validate",
|
||||
geetest_challenge_path="$.data.challenge",
|
||||
geetest_result_path="",
|
||||
geetest_result_path="$",
|
||||
get_geetest_url="",
|
||||
get_geetest_method: Literal["post", "get"] = "post",
|
||||
get_geetest_params: Optional[dict] = None,
|
||||
get_geetest_data: Optional[dict] = None,
|
||||
get_geetest_validate_path="",
|
||||
get_geetest_challenge_path="",
|
||||
get_geetest_validate_path="$",
|
||||
get_geetest_challenge_path="$",
|
||||
):
|
||||
self.geetest_url = geetest_url
|
||||
"""极验验证URL"""
|
||||
|
@ -8,12 +8,13 @@ LastEditTime: 2025-01-19 16:48:47
|
||||
import platform
|
||||
from urllib.request import getproxies
|
||||
|
||||
from utils.__version__ import VERSION
|
||||
from utils.logger import log
|
||||
|
||||
|
||||
def print_info():
|
||||
"""打印系统信息"""
|
||||
log.info("MIUI-AUTO-TASK v1.7.5")
|
||||
log.info(f"MIUI-AUTO-TASK {VERSION}")
|
||||
log.info("---------- 系统信息 -------------")
|
||||
system_info()
|
||||
log.info("---------- 项目信息 -------------")
|
||||
|
@ -8,10 +8,9 @@ from io import BytesIO
|
||||
from typing import Type
|
||||
from urllib.parse import parse_qsl, urlparse
|
||||
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives import padding, serialization
|
||||
from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15
|
||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||
from Crypto.Cipher import AES, PKCS1_v1_5
|
||||
from Crypto.PublicKey import RSA
|
||||
from Crypto.Util.Padding import pad
|
||||
from qrcode import QRCode, constants
|
||||
from tenacity import RetryError, Retrying, stop_after_attempt
|
||||
|
||||
@ -56,27 +55,20 @@ def get_random_chars_as_string(
|
||||
return "".join(random.choice(characters) for _ in range(length))
|
||||
|
||||
|
||||
def aes_encrypt(key: str, data: str) -> base64:
|
||||
"""AES加密"""
|
||||
iv = b"0102030405060708" # pylint: disable=invalid-name
|
||||
cipher = Cipher(
|
||||
algorithms.AES(key.encode("utf-8")), modes.CBC(iv), backend=default_backend()
|
||||
)
|
||||
encryptor = cipher.encryptor()
|
||||
padder = padding.PKCS7(algorithms.AES.block_size).padder()
|
||||
padded_data = padder.update(data.encode("utf-8")) + padder.finalize()
|
||||
ciphertext = encryptor.update(padded_data) + encryptor.finalize()
|
||||
def aes_encrypt(key: str, data: str):
|
||||
"""AES 加密"""
|
||||
iv = "0102030405060708".encode("utf-8")
|
||||
cipher = AES.new(key.encode("utf-8"), AES.MODE_CBC, iv)
|
||||
padded_data = pad(data.encode("utf-8"), AES.block_size, style="pkcs7")
|
||||
ciphertext = cipher.encrypt(padded_data)
|
||||
return base64.b64encode(ciphertext).decode("utf-8")
|
||||
|
||||
|
||||
def rsa_encrypt(public_key_pem: str, data: str) -> base64:
|
||||
"""RSA加密"""
|
||||
public_key = serialization.load_pem_public_key(
|
||||
public_key_pem.encode("utf-8"), backend=default_backend()
|
||||
)
|
||||
encoded_data = base64.b64encode(data.encode("utf-8"))
|
||||
ciphertext = public_key.encrypt(encoded_data, PKCS1v15())
|
||||
|
||||
def rsa_encrypt(key: str, data: str):
|
||||
"""RSA 加密"""
|
||||
public_key = RSA.import_key(key)
|
||||
cipher = PKCS1_v1_5.new(public_key)
|
||||
ciphertext = cipher.encrypt(base64.b64encode(data.encode("utf-8")))
|
||||
return base64.b64encode(ciphertext).decode("utf-8")
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user