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

90 lines
3.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 -*-
"""把 ha-connections=2 这个发现写进 install.sh。
实测数据(这条 4G 线路上):
ha=4 -> 9/10,而且只成功注册 1 条连接(其余一直在握手超时)
ha=2 -> 10/10,2 条都注册
ha=1 -> 10/10,1 条
定稿后再测:ha=2 连打 30 次,29/30 成功,0 次断开,0 次 quic 错误。
原因推测:这条线路对并发 UDP 有节制,4 条 QUIC 同时握手互相挤,
反而条条失败。2 条是甜点:够稳,又还有冗余。
install.sh 原来写的 `--ha-connections 4` 要改掉。
"""
from __future__ import annotations
import sys
from pathlib import Path
INSTALL = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\relay"
r"\install.sh")
OLD = '''ExecStart=/usr/local/bin/cloudflared tunnel --no-autoupdate --edge-ip-version 4 --config $CONF run $TUNNEL_NAME'''
NEW = '''# ha-connections=2 是实测调出来的(不是拍脑袋):
# 这条 4G 线路对并发 UDP 有节制,4 条 QUIC 同时握手会互相挤,
# 结果只成功 1 条、可用率 9/10;降到 2 条后 10/10,
# 而且仍有冗余(连两个不同的边缘节点)。
ExecStart=/usr/local/bin/cloudflared tunnel --no-autoupdate --edge-ip-version 4 --ha-connections 2 --retries 5 --config $CONF run $TUNNEL_NAME'''
ANCHOR2 = ''' install.sh 里给 cloudflared 加了:
--edge-ip-version 4 只走 IPv4
--protocol http2'''
NEW2 = ''' install.sh 里给 cloudflared 加了:
--edge-ip-version 4 只走 IPv4
--ha-connections 2 并发连接数(实测调出来的,见下)
--retries 5 连边缘失败时多重试
关于协议:**用默认的 QUIC,不要指定 http2**。
实测这条线路把 HTTP/2 用的 TCP 7844 挡了(TLS 握手超时),
而 QUIC 走 UDP 7844 是通的。
关于连接数:默认是 4,但这条线路上 4 条并发 QUIC 握手会互相挤,
只成功 1 条、可用率 9/10。降到 2 条后 10/10,
定稿后连打 30 次 29/30 成功、0 次断开。'''
def main() -> int:
text = INSTALL.read_text(encoding="utf-8")
ok = True
if "--ha-connections 2" in text:
print(" install.sh 已经是 ha-connections 2")
elif OLD in text:
text = text.replace(OLD, NEW, 1)
print(" install.sh: 自启单元加了 --ha-connections 2 --retries 5")
else:
print(" [失败] 找不到 ExecStart 锚点")
# 打出来看看实际长什么样
for line in text.splitlines():
if "ExecStart" in line and "cloudflared" in line:
print(f" 实际: {line.strip()[:110]}")
ok = False
if ANCHOR2 in text:
text = text.replace(ANCHOR2, NEW2, 1)
print(" install.sh: 说明文档更新(协议 + 连接数)")
elif "--ha-connections 2" in text and "连接数" in text:
print(" install.sh: 说明已经更新过")
else:
print(" [跳过] 说明锚点没找到")
INSTALL.write_text(text, encoding="utf-8", newline="\n")
raw = INSTALL.read_bytes()
if b"\r\n" in raw:
INSTALL.write_bytes(raw.replace(b"\r\n", b"\n"))
print(" 顺手修了 CRLF")
# 复核
text = INSTALL.read_text(encoding="utf-8")
for line in text.splitlines():
if "ExecStart" in line and "cloudflared" in line:
print(f" 现在: {line.strip()[:120]}")
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())