Files
ykxmz/_build/patch_custom_code.py
T
xmz7891 b62ac865ea ykxmz 1.5.0:修复手表端 TLS 证书校验 + MTU 修复网络稳定性
被控端
- 修复 MTU 问题:夹 MSS + 路径 MTU 探测(公网可用率 48% -> 100%)
- 复用 HTTP 连接(免掉每次新建 TLS 的 30% 握手失败)
- 每分钟回头找局域网,自动切回快 400 倍的路径
- 画面心跳帧:静止时省流量,客户端仍知道流是活的
- 锁屏时给出可操作的提示

手表端
- 内置 GTS Root R4 / GlobalSign Root CA,修 SSLHandshakeException
- 连接错误翻译成人话(证书/时间/解析/超时分别提示)
- 经中转连上后用服务器报的地址刷新已配对记录
- 新增局域网连接页面、服务器延迟检测

服务器端
- 支持 chunked 请求体(修每 16 秒一次的连接错乱与大面积 502)
- 网络调优脚本 net-tune.sh(开机自动应用)
- 管理页:批量删除、网络体检、下载区
- 隧道改 HTTP/2 + 双连接

文档
- 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
2026-10-06 19:01:05 +08:00

133 lines
5.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.
# -*- coding: utf-8 -*-
"""允许用户把自己的配对码设成任意 6-16 位。
为什么不是硬编码:
硬编码意味着**每一台装了这软件的被控端都是同一个码**,
而且这个码还会被打进手表 APK(APK 可以反编译)。
泄露一次 = 所有用户一起中招,这就是"默认密码"型漏洞。
让用户在自己的机器上设,性质完全不同:
这是你这台电脑的凭据,只存在你的 data/settings.json 里,
不出现在任何分发的文件里,你随时能改。
配套:
* 最少 6 位(6 位已经是 100 万种,加上现有的限速够用)
* 暴力枚举限速保留(10 次失败锁 5 分钟)
* 设置里能看、能改、能一键换回随机码
"""
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\windows"
r"\lanremote")
CONFIG = ROOT / "config.py"
UI = ROOT / "ui.py"
# ---------------- config:设置码 ----------------
CONFIG_ANCHOR = ''' def pairing_code(self) -> str:
return self.get("pairing_code", "")'''
CONFIG_NEW = ''' MIN_CODE_LEN = 6
MAX_CODE_LEN = 16
def set_pairing_code(self, code: str) -> str:
"""设成用户自己的配对码。返回规范化后的值。
只存在本机 data/settings.json 里,不写进任何要分发的东西。
"""
cleaned = "".join(ch for ch in str(code or "").strip()
if ch.isdigit() or ch.isalpha())
if len(cleaned) < self.MIN_CODE_LEN:
raise ValueError(f"配对码至少 {self.MIN_CODE_LEN} 位")
if len(cleaned) > self.MAX_CODE_LEN:
raise ValueError(f"配对码最多 {self.MAX_CODE_LEN} 位")
with self._lock:
self.settings["pairing_code"] = cleaned
self.settings["pairing_created"] = time.time()
self.save_settings()
return cleaned
def pairing_code(self) -> str:
return self.get("pairing_code", "")'''
# ---------------- ui:设置里加一项 ----------------
UI_ANCHOR = ''' # ---- 开机自启 ----
row_label("开机自启", "开机后在后台静默运行,没有任何窗口")'''
UI_NEW = ''' # ---- 配对码 ----
row_label("配对码", "6-16 位,只存本机。配一次就记住,平时不用输")
code_row = tk.Frame(win, bg=BG)
code_row.pack(fill="x", padx=16)
ent_code = tk.Entry(code_row, bg=CARD, fg=FG, relief="flat",
font=FONT_SMALL, width=14,
highlightthickness=1, highlightbackground=BORDER)
ent_code.insert(0, str(self.store.pairing_code() or ""))
ent_code.pack(side="left", ipady=4)
def randomize():
"""换一组随机码。"""
ent_code.delete(0, "end")
ent_code.insert(0, self.store.new_pairing_code())
self._btn(code_row, "换随机码", randomize, width=9, last=True)
# ---- 开机自启 ----
row_label("开机自启", "开机后在后台静默运行,没有任何窗口")'''
UI_SAVE_ANCHOR = ''' # 开机自启(可能失败:权限/注册表被锁)'''
UI_SAVE_NEW = ''' # 配对码
code_note = ""
typed = ent_code.get().strip()
if typed and typed != self.store.pairing_code():
try:
self.store.set_pairing_code(typed)
code_note = f";配对码已改为 {typed}"
except ValueError as exc:
code_note = f";配对码没改({exc})"
# 开机自启(可能失败:权限/注册表被锁)'''
UI_LOG_ANCHOR = ''' self.log(f"设置已保存;已关闭:{'、'.join(off)}{auto_note}")
else:
self.log(f"设置已保存(音色={chosen},语速={rate}){auto_note}")'''
UI_LOG_NEW = ''' self.log(f"设置已保存;已关闭:{'、'.join(off)}"
f"{auto_note}{code_note}")
else:
self.log(f"设置已保存(音色={chosen},语速={rate})"
f"{auto_note}{code_note}")'''
def main() -> int:
ok = True
for path, old, new, tag in ((CONFIG, CONFIG_ANCHOR, CONFIG_NEW, "config: 自定义配对码"),
(UI, UI_ANCHOR, UI_NEW, "ui: 配对码输入框"),
(UI, UI_SAVE_ANCHOR, UI_SAVE_NEW, "ui: 保存配对码"),
(UI, UI_LOG_ANCHOR, UI_LOG_NEW, "ui: 日志文案")):
text = path.read_text(encoding="utf-8")
if old not in text:
print(f" [跳过] {tag} —— 锚点没找到")
ok = False
continue
path.write_text(text.replace(old, new, 1), encoding="utf-8")
print(f" {tag}: OK")
import ast
for label, path in (("config.py", CONFIG), ("ui.py", UI)):
try:
ast.parse(path.read_text(encoding="utf-8"))
print(f" {label}: 语法 OK")
except SyntaxError as exc:
print(f" {label}: 语法错误 {exc}")
ok = False
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())