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

67 lines
2.4 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 -*-
"""修看门狗测试的断言。
错在哪:我用 `NRestarts` 判断看门狗有没有重启隧道。
但 `NRestarts` **只统计 Restart=always 的自动重启**,
`systemctl restart` 这种手动重启不算在里面 —— 所以永远看到 0。
该看的是:
* 看门狗日志里有没有「连续 3 次不通 -> 重启隧道」
* 地址有没有变(变了就说明隧道被重启并重新申请了地址)
"""
from __future__ import annotations
import sys
from pathlib import Path
TARGET = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\_build"
r"\test_watchdog_restart.sh")
OLD_JUDGE = '''if [ "$AFTER" -gt "$BEFORE" ]; then
echo " ✓ 看门狗确实触发了隧道重启"
else
echo " ✗ 看门狗没重启隧道 —— 逻辑有问题"
fi'''
NEW_JUDGE = '''# 注意:NRestarts 只统计 Restart=always 的**自动**重启,
# 不含 systemctl restart 的手动重启。所以不能拿它判断。
# 该看的是:日志里有没有「连续 3 次不通」,以及地址有没有变。
if grep -q "连续 3 次不通" "$RELAY_DIR/watchdog.log" 2>/dev/null; then
echo " ✓ 看门狗日志里有「连续 3 次不通 -> 重启隧道」"
else
echo " ✗ 日志里没看到触发重启"
fi
if [ -n "$NEW_URL" ] && [ "$NEW_URL" != "$BEFORE_URL" ]; then
echo " ✓ 地址确实变了(说明隧道被重启并重新申请了地址)"
else
echo " ~ 地址没变"
fi'''
OLD_MARK = '''BEFORE=$(systemctl show lanremote-tunnel -p NRestarts | cut -d= -f2)'''
NEW_MARK = '''BEFORE=$(systemctl show lanremote-tunnel -p NRestarts | cut -d= -f2)
BEFORE_URL=$(cat "$URL_FILE" 2>/dev/null || echo "")'''
def main() -> int:
text = TARGET.read_text(encoding="utf-8")
ok = True
for old, new, tag in ((OLD_JUDGE, NEW_JUDGE, "判定逻辑"),
(OLD_MARK, NEW_MARK, "记录重启前地址")):
if old in text:
text = text.replace(old, new, 1)
print(f" {tag}: 已改")
else:
print(f" [跳过] {tag} —— 锚点没找到")
ok = False
TARGET.write_text(text, encoding="utf-8", newline="\n")
raw = TARGET.read_bytes()
if b"\r\n" in raw:
TARGET.write_bytes(raw.replace(b"\r\n", b"\n"))
print(" 顺手修了 CRLF")
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())