Files
ykxmz/_build/patch_backend_wire.py
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

161 lines
5.9 KiB
Python
Raw Permalink 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 -*-
"""补上:Actions 的初始化字段、剪贴板历史、服务端 13 个新命令的处理。"""
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\windows\lanremote")
ACTIONS = ROOT / "actions.py"
SERVER = ROOT / "server.py"
# ---- Actions 初始化 ----
INIT_OLD = ''' self._audio_alias: str | None = None
self._image_window = None
self._lock = threading.RLock()'''
INIT_NEW = ''' self._audio_alias: str | None = None
self._image_window = None
self._lock = threading.RLock()
# 剪贴板历史(最近 20 条)
self._clip_history: list[dict] = []
# CPU 占用要两次采样才算得出来
self._last_cpu_total = 0
self._last_cpu_idle = 0'''
# ---- clip_set 记历史 ----
CLIP_OLD = ''' self.ui.ui_call(do)
return f"剪贴板已更新({len(text)} 字符)"'''
CLIP_NEW = ''' self.ui.ui_call(do)
self.store.set("last_clip", text)
self._remember_clip(text)
return f"剪贴板已更新({len(text)} 字符)"'''
# ---- 服务端命令处理 ----
SERVER_ANCHOR = ''' if cmd == P.CMD_SET_VOICE:'''
SERVER_NEW = ''' if cmd == P.CMD_SHUTDOWN_TIMER:
cancel = bool(msg.get("cancel"))
try:
minutes = int(msg.get("minutes") or 0)
except (TypeError, ValueError):
minutes = 0
note = self.actions.shutdown_timer(minutes, cancel)
self._log(f"[电源] {note}")
return {"ok": True, "note": note}
if cmd == P.CMD_MONITOR:
note = self.actions.monitor_power(bool(msg.get("on")))
self._log(f"[显示] {note}")
return {"ok": True, "note": note}
if cmd == P.CMD_OPEN_URL:
note = self.actions.open_url(str(msg.get("url") or ""))
self._log(f"[网址] {note}")
return {"ok": True, "note": note}
if cmd == P.CMD_QUICK:
note = self.actions.quick_launch(str(msg.get("app") or ""))
self._log(f"[快捷] {note}")
return {"ok": True, "note": note}
if cmd == P.CMD_OPEN_FOLDER:
note = self.actions.open_folder(str(msg.get("folder") or ""))
self._log(f"[文件夹] {note}")
return {"ok": True, "note": note}
if cmd == P.CMD_PROC_LIST:
procs = self.actions.list_processes()
return {"ok": True,
"names": [f"{p['name']} ({p['mem_kb'] // 1024} MB)" for p in procs],
"pids": [p["pid"] for p in procs]}
if cmd == P.CMD_PROC_KILL:
try:
pid = int(msg.get("pid") or 0)
except (TypeError, ValueError):
pid = 0
note = self.actions.kill_process(pid, str(msg.get("name") or ""))
self._log(f"[进程] {note}")
return {"ok": True, "note": note}
if cmd == P.CMD_BATTERY:
info = self.actions.battery()
if not info.get("present"):
return {"ok": True, "note": info.get("note") or "没有电池(台式机)"}
detail = f"{info['percent']}%"
if info.get("charging"):
detail += "(充电中)"
return {"ok": True, "note": detail, **info}
if cmd == P.CMD_DISK:
drives = self.actions.disk()
lines = [f"{d['drive']} {d['free_gb']}/{d['total_gb']} GB 可用"
f"(已用 {d['used_percent']}%)" for d in drives]
return {"ok": True, "note": " | ".join(lines) or "读不到磁盘",
"drives": drives}
if cmd == P.CMD_PERF:
info = self.actions.perf()
note = (f"CPU {info.get('cpu_percent')}% "
f"内存 {info.get('mem_percent')}%"
f"({info.get('mem_used_gb')}/{info.get('mem_total_gb')} GB)")
return {"ok": True, "note": note, **info}
if cmd == P.CMD_CLIP_HISTORY:
items = self.actions.clip_history()
return {"ok": True, "note": f"共 {len(items)} 条",
"texts": [i.get("text", "") for i in items],
"times": [i.get("at", "") for i in items]}
if cmd == P.CMD_SET_WALLPAPER:
note = self.actions.set_wallpaper(str(msg.get("path") or ""))
self._log(f"[壁纸] {note}")
return {"ok": True, "note": note}
if cmd == P.CMD_SAY_CLIP:
note = self.actions.say_clipboard()
self._log(f"[朗读] 剪贴板内容")
return {"ok": True, "note": note}
if cmd == P.CMD_SET_VOICE:'''
def main() -> int:
ok = True
text = ACTIONS.read_text(encoding="utf-8")
for old, new, tag in ((INIT_OLD, INIT_NEW, "初始化字段"),
(CLIP_OLD, CLIP_NEW, "剪贴板历史")):
if old not in text:
print(f" [失败] actions.py {tag} 锚点未匹配")
ok = False
else:
text = text.replace(old, new, 1)
print(f" actions.py / {tag}: OK")
if ok:
ACTIONS.write_text(text, encoding="utf-8")
stext = SERVER.read_text(encoding="utf-8")
if SERVER_ANCHOR not in stext:
print(" [失败] server.py 锚点未匹配")
ok = False
else:
stext = stext.replace(SERVER_ANCHOR, SERVER_NEW, 1)
SERVER.write_text(stext, encoding="utf-8")
print(" server.py / 13 个新命令: OK")
print("\n语法检查:")
import ast
for name, path in (("actions.py", ACTIONS), ("server.py", SERVER)):
try:
ast.parse(path.read_text(encoding="utf-8"))
print(f" {name}: OK")
except SyntaxError as exc:
print(f" {name}: 语法错误 {exc}")
ok = False
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())