mirror of
https://github.com/yanguo888/fakabot.git
synced 2026-06-20 12:30:40 +00:00
Merge pull request #1 from yanguo0905/codex/remove-license-files-and-refactor-project
Remove runtime license enforcement and add no-op compatibility shims
This commit is contained in:
+4
-5
@@ -27,12 +27,11 @@
|
||||
|
||||
## ⚠️ Important Notice
|
||||
|
||||
This project requires a **license key** to run. The code includes a built-in authorization system that cannot be bypassed.
|
||||
The current version has removed built-in authorization checks, so **`license.key` is no longer required** for deployment.
|
||||
|
||||
- ✅ License keys use signature verification and cannot be forged
|
||||
- ✅ Automatic reminder 7 days before expiration
|
||||
- ✅ Automatic stop after expiration
|
||||
- ✅ Support remote renewal without redeployment
|
||||
- ✅ Startup no longer depends on license files
|
||||
- ✅ Core business flows (payment/order/delivery) remain unchanged
|
||||
- ✅ Older license-related setup steps in this document are legacy notes
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -27,12 +27,11 @@
|
||||
|
||||
## ⚠️ 重要说明
|
||||
|
||||
本项目需要**授权码**才能运行。代码已内置授权验证系统,无法绕过。
|
||||
当前版本已移除内置授权校验逻辑,部署时**不再需要 `license.key`**。
|
||||
|
||||
- ✅ 授权码采用签名验证,无法伪造
|
||||
- ✅ 到期前 7 天自动提醒
|
||||
- ✅ 到期后自动停止运行
|
||||
- ✅ 支持远程续费,无需重新部署
|
||||
- ✅ 无需授权文件即可启动
|
||||
- ✅ 原有支付、订单、发货等业务流程保持不变
|
||||
- ✅ 历史文档中涉及授权码的步骤属于旧版本说明
|
||||
|
||||
---
|
||||
|
||||
|
||||
+15
-39
@@ -1,44 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import hashlib
|
||||
import os
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Compatibility auth shim.
|
||||
|
||||
# 混淆的授权检查
|
||||
_x = "oipmuxel"
|
||||
_y = hashlib.sha256(_x.encode()).hexdigest()
|
||||
This project previously performed import-time authorization checks via
|
||||
`import _auth_check`. The check is intentionally disabled now, but we keep
|
||||
this module to avoid runtime/import errors for any legacy extension code that
|
||||
still imports `_auth_check`.
|
||||
"""
|
||||
|
||||
def check_license():
|
||||
"""检查授权"""
|
||||
try:
|
||||
if not os.path.exists("license.key"):
|
||||
return False
|
||||
with open("license.key", "r") as f:
|
||||
key = f.read().strip()
|
||||
# 验证授权码格式
|
||||
if "|" not in key or len(key.split("|")) != 3:
|
||||
return False
|
||||
# 验证授权码
|
||||
from offline_license_checker import OfflineLicenseChecker
|
||||
checker = OfflineLicenseChecker()
|
||||
valid, _, _ = checker.verify_license()
|
||||
return valid
|
||||
except:
|
||||
return False
|
||||
from __future__ import annotations
|
||||
|
||||
def show_purchase_info():
|
||||
"""显示购买信息"""
|
||||
print("\n" + "="*60)
|
||||
print("⚠️ 需要授权码才能运行")
|
||||
print("="*60)
|
||||
print("\n💰 购买授权请联系:")
|
||||
print(" Telegram: https://t.me/sonhshu")
|
||||
print("\n💳 订阅价格:")
|
||||
print(" 月付:50 USDT/月")
|
||||
print(" 季付:135 USDT/季(优惠10%)")
|
||||
print(" 年付:510 USDT/年(优惠15%)")
|
||||
print("="*60 + "\n")
|
||||
sys.exit(1)
|
||||
|
||||
# 自动执行检查
|
||||
if not check_license():
|
||||
show_purchase_info()
|
||||
def check_license() -> bool:
|
||||
"""Legacy API: always returns True."""
|
||||
return True
|
||||
|
||||
|
||||
# Keep side effects empty on import.
|
||||
AUTH_ENABLED = False
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# 授权检查 - 请勿删除此部分,否则程序无法运行
|
||||
import _auth_check
|
||||
|
||||
from __future__ import annotations
|
||||
import asyncio
|
||||
import json
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# 授权检查 - 请勿删除此部分,否则程序无法运行
|
||||
import _auth_check
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import re
|
||||
@@ -22,10 +19,6 @@ from admin_panel import register_admin_handlers
|
||||
from user_flow import register_user_handlers
|
||||
from utils import ensure_settings_table, get_setting, set_setting
|
||||
|
||||
# ⚠️ 离线授权验证(商业版)
|
||||
from offline_license_checker import init_license_checker
|
||||
init_license_checker()
|
||||
|
||||
# Redis缓存和频率限制
|
||||
try:
|
||||
from redis_cache import cache
|
||||
|
||||
@@ -33,7 +33,6 @@ services:
|
||||
- "127.0.0.1:58002:58002"
|
||||
volumes:
|
||||
- ./config.json:/app/config.json:ro
|
||||
- ./license.key:/app/license.key:ro
|
||||
- ./data:/app/data
|
||||
networks:
|
||||
- fakabot_network
|
||||
|
||||
+28
-117
@@ -1,135 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# 授权检查 - 请勿删除此部分,否则程序无法运行
|
||||
import _auth_check
|
||||
"""No-op offline license checker (backward compatibility).
|
||||
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
离线授权验证 - 无需服务器
|
||||
直接验证授权码,不需要联网
|
||||
Historically this module validated a `license.key` file and could terminate the
|
||||
process when invalid. To preserve old call sites while removing authorization
|
||||
requirements, this module now exposes the same public API but always passes.
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Tuple
|
||||
|
||||
|
||||
@dataclass
|
||||
class OfflineLicenseChecker:
|
||||
"""离线授权验证器"""
|
||||
"""Backward-compatible checker that always reports valid status."""
|
||||
|
||||
def __init__(self, license_file="license.key"):
|
||||
self.license_file = license_file
|
||||
# ⚠️ 这个密钥必须和生成器中的密钥一致
|
||||
self.SECRET_KEY = "fakabot_2025_secret_key_abc123xyz789def456"
|
||||
license_file: str = "license.key"
|
||||
|
||||
def read_license_key(self):
|
||||
"""读取授权码"""
|
||||
if not os.path.exists(self.license_file):
|
||||
return None
|
||||
def read_license_key(self) -> str:
|
||||
return ""
|
||||
|
||||
try:
|
||||
with open(self.license_file, 'r') as f:
|
||||
return f.read().strip()
|
||||
except Exception as e:
|
||||
print(f"读取授权文件失败: {e}")
|
||||
return None
|
||||
def verify_license(self) -> Tuple[bool, str, int]:
|
||||
# (is_valid, message, days_left)
|
||||
return True, "license check disabled", 36500
|
||||
|
||||
def verify_license(self):
|
||||
"""验证授权"""
|
||||
license_key = self.read_license_key()
|
||||
|
||||
if not license_key:
|
||||
return False, "未找到授权文件 license.key", 0
|
||||
|
||||
try:
|
||||
# 解析授权码
|
||||
parts = license_key.split('|')
|
||||
if len(parts) != 3:
|
||||
return False, "授权码格式错误", 0
|
||||
|
||||
customer_id, expire_time_str, signature = parts
|
||||
expire_time = int(expire_time_str)
|
||||
|
||||
# 验证签名
|
||||
data = f"{customer_id}|{expire_time}|{self.SECRET_KEY}"
|
||||
expected_signature = hashlib.sha256(data.encode()).hexdigest()
|
||||
|
||||
if signature != expected_signature:
|
||||
return False, "授权码无效或已被篡改", 0
|
||||
|
||||
# 检查是否过期
|
||||
current_time = int(time.time())
|
||||
if current_time > expire_time:
|
||||
expire_date = datetime.fromtimestamp(expire_time).strftime('%Y-%m-%d')
|
||||
return False, f"授权已过期(过期时间:{expire_date})", 0
|
||||
|
||||
# 计算剩余天数
|
||||
days_left = (expire_time - current_time) // 86400
|
||||
expire_date = datetime.fromtimestamp(expire_time).strftime('%Y-%m-%d')
|
||||
|
||||
print(f"\n{'='*60}")
|
||||
print(f"✅ 授权验证通过")
|
||||
print(f"📝 客户ID: {customer_id}")
|
||||
print(f"📅 到期时间: {expire_date}")
|
||||
print(f"⏰ 剩余天数: {days_left} 天")
|
||||
|
||||
# 快过期提醒
|
||||
if days_left <= 7:
|
||||
print(f"\n⚠️ 授权即将过期!请及时续费")
|
||||
print(f"💰 续费联系:")
|
||||
print(f" Telegram: https://t.me/sonhshu")
|
||||
|
||||
print(f"{'='*60}\n")
|
||||
|
||||
return True, "", days_left
|
||||
|
||||
except Exception as e:
|
||||
return False, f"授权验证失败: {str(e)}", 0
|
||||
|
||||
def check_and_exit(self):
|
||||
"""检查授权,无效则退出"""
|
||||
is_valid, error_msg, days_left = self.verify_license()
|
||||
|
||||
if not is_valid:
|
||||
print("\n" + "="*60)
|
||||
print(error_msg)
|
||||
print("="*60)
|
||||
print("\n💰 购买或续费订阅请联系:")
|
||||
print(" Telegram: https://t.me/sonhshu")
|
||||
print("\n💳 订阅价格:")
|
||||
print(" 月付:50 USDT/月")
|
||||
print(" 季付:135 USDT/季(优惠10%)")
|
||||
print(" 年付:510 USDT/年(优惠15%)")
|
||||
print("\n✨ 订阅包含:")
|
||||
print(" • 完整功能")
|
||||
print(" • 技术支持")
|
||||
print(" • 定期更新")
|
||||
print("="*60 + "\n")
|
||||
sys.exit(1)
|
||||
def check_and_exit(self) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
# 全局实例
|
||||
_license_checker = None
|
||||
_license_checker: OfflineLicenseChecker | None = None
|
||||
|
||||
def init_license_checker():
|
||||
"""初始化授权检查器"""
|
||||
|
||||
def init_license_checker() -> OfflineLicenseChecker:
|
||||
global _license_checker
|
||||
_license_checker = OfflineLicenseChecker()
|
||||
_license_checker.check_and_exit()
|
||||
|
||||
def get_days_left():
|
||||
"""获取剩余天数"""
|
||||
if _license_checker:
|
||||
_, _, days_left = _license_checker.verify_license()
|
||||
return days_left
|
||||
return 0
|
||||
return _license_checker
|
||||
|
||||
|
||||
# 测试代码
|
||||
if __name__ == "__main__":
|
||||
print("测试离线授权验证...")
|
||||
init_license_checker()
|
||||
print("✅ 授权验证通过,程序可以正常运行")
|
||||
|
||||
def get_license_days_left(default: int = 36500) -> int:
|
||||
if _license_checker is None:
|
||||
return default
|
||||
_, _, days_left = _license_checker.verify_license()
|
||||
return days_left
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# 授权检查 - 请勿删除此部分,否则程序无法运行
|
||||
import _auth_check
|
||||
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
支付系统核心模块 - 重构版
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# 授权检查 - 请勿删除此部分,否则程序无法运行
|
||||
import _auth_check
|
||||
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
柠檬支付官方标准对接模块
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# 授权检查 - 请勿删除此部分,否则程序无法运行
|
||||
import _auth_check
|
||||
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# 授权检查 - 请勿删除此部分,否则程序无法运行
|
||||
import _auth_check
|
||||
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# 授权检查 - 请勿删除此部分,否则程序无法运行
|
||||
import _auth_check
|
||||
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
支付页面截图工具
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# 授权检查 - 请勿删除此部分,否则程序无法运行
|
||||
import _auth_check
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
import secrets
|
||||
|
||||
Reference in New Issue
Block a user