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

103 lines
4.4 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 -*-
"""修两个由之前修复引入的回归。
1. _resolve_received:我插入的相对路径检查提前 return None,
把后面"按文件名在接收目录里找"的逻辑整个挡住了 —— file_pull 全废。
相对路径要「检查完继续往下走」,而不是直接返回。
2. test_features.py:把「额外允许的目录」建在了数据目录里面,
被新的敏感目录检查拦住(行为正确,是测试的位置不对)。
"""
from __future__ import annotations
import sys
from pathlib import Path
SERVER = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\windows"
r"\lanremote\server.py")
TEST = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\_tests"
r"\test_features.py")
SRV_OLD = ''' # 相对路径也要过白名单。Path("data/settings.json").is_absolute() 是 False,
# 上面那一段挡不住它 —— 而 EXE 的 CWD 就是程序目录,
# 于是已配对设备能把 data/settings.json(配对码 + 全部设备令牌)拉走。
try:
relative = (Path.cwd() / raw).resolve()
except OSError:
return None
allowed_roots = [self.store.received_dir()]
if self.features is not None:
allowed_roots.extend(self.features.allowed_roots())
if self._is_sensitive(relative):
self._log(f"[文件] 拒绝拉取数据目录: {raw}")
return None
for root in allowed_roots:
try:
relative.relative_to(root.resolve())
return relative if relative.is_file() else None
except (ValueError, OSError):
continue
self._log(f"[文件] 拒绝拉取相对路径: {raw}")
return None'''
SRV_NEW = ''' # 相对路径也要过一遍检查。Path("data/settings.json").is_absolute() 是 False,
# 上面那一段挡不住它 —— 而 EXE 的 CWD 就是程序目录,
# 于是已配对设备能把 data/settings.json(配对码 + 全部设备令牌)拉走。
#
# 注意:这里**不能**因为"不在允许目录内"就 return None ——
# 后面的逻辑还要按文件名在接收目录里找。只有命中敏感目录时才直接拒绝。
try:
relative = (Path.cwd() / raw).resolve()
except OSError:
relative = None
if relative is not None:
if self._is_sensitive(relative):
self._log(f"[文件] 拒绝拉取数据目录: {raw}")
return None
allowed_roots = [self.store.received_dir()]
if self.features is not None:
allowed_roots.extend(self.features.allowed_roots())
for root in allowed_roots:
try:
relative.relative_to(root.resolve())
if relative.is_file():
return relative
break # 在允许目录内但不是文件,交给下面按名字找
except (ValueError, OSError):
continue
# 落到下面:按文件名在「接收目录」里找最新的那一份'''
# 测试:额外目录建在数据目录外面
TEST_OLD = ''' extra = tmp / "课件"'''
TEST_NEW = ''' # 额外目录要建在数据目录**外面** —— 数据目录整个都是敏感的
# (里面有配对码和设备令牌),建在里面会被正确地拒绝。
import tempfile as _tf
extra = Path(_tf.mkdtemp(prefix="lr_extra_")) / "课件"'''
def main() -> int:
ok = True
for path, old, new, tag in ((SERVER, SRV_OLD, SRV_NEW, "file_pull 按名字查找恢复"),
(TEST, TEST_OLD, TEST_NEW, "测试的额外目录挪出数据目录")):
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 (("server.py", SERVER), ("test_features.py", TEST)):
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())