Files
ReinLoopTest/ReinLoop/core/__init__.py
T
2026-08-03 15:18:28 +08:00

40 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# core/__init__.py
"""core 包 —— 业务逻辑层。
模块级许可证校验:import 此包的瞬间自动执行验签。
两个文件均编译为 .pyd → 无法被篡改绕过。
"""
import sys
# ============================================================
# 模块级验签 —— 每次 import core.xxx 必然触发
# 效果等同于在 main.py 中调用 check_license()
# 但此文件编译进 .pyd,攻击者无法删除或修改。
# ============================================================
_LICENSE_CHECKED = False
def _init_license():
"""在模块加载时自动调用一次,验证许可证。"""
global _LICENSE_CHECKED
if _LICENSE_CHECKED:
return
# 开发环境(非 PyInstaller 打包)→ 直接跳过,不打扰
# if not getattr(sys, 'frozen', False):
# print("[core] 开发环境:跳过许可证校验")
# _LICENSE_CHECKED = True
# return
# 生产环境(exe 打包)→ 严格执行验签
from license_utils import check_license
check_license() # 仅启动时验签,失败直接退出
_LICENSE_CHECKED = True
# 导入时立即执行
_init_license()