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

99 lines
3.3 KiB
Bash
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.
#!/bin/bash
# 回退到 QUIC,并做抗抖动调优。
#
# 实测结论(很明确):
# HTTP/2 走 TCP 7844 -> "TLS handshake with edge ... i/o timeout"
# 这条线路把 TCP 7844 挡了
# QUIC 走 UDP 7844 -> 能连上(虽然偶尔抖)
# 所以**只能用 QUIC**,之前的 502/530 是线路抖动,不是协议选错。
#
# 抗抖动调优:
# 1. --ha-connections 4 同时保持 4 条到边缘的连接(默认值,显式写上)
# 2. --retries 5 连边缘失败时多重试
# 3. 中转的长轮询从 25 秒降到 15 秒
# 长连接更容易被抖动打断;短一点反而更稳,
# 而且断了一条只影响 15 秒的请求,不是 25 秒。
set -u
RELAY_DIR=/root/lanremote-relay
echo "===== 1. 写回 QUIC + 调优参数 ====="
cat > /etc/systemd/system/lanremote-tunnel.service <<EOF
[Unit]
Description=LanRemote Cloudflare 具名隧道
After=network-online.target lanremote-relay.service
Wants=network-online.target
Requires=lanremote-relay.service
[Service]
Type=simple
# 必须用 QUIC(默认):
# 实测这条 4G 线路把 HTTP/2 用的 TCP 7844 挡了
# (TLS handshake timeout),而 QUIC 走 UDP 7844 是通的。
# --ha-connections 4 同时保持 4 条连接,抖掉一条还有别的。
# --retries 5 连不上边缘时多重试几次。
ExecStart=/usr/local/bin/cloudflared tunnel --no-autoupdate --edge-ip-version 4 --ha-connections 4 --retries 5 --config /root/.cloudflared/config.yml run lanremote
Restart=always
RestartSec=5
MemoryMax=128M
StandardOutput=append:$RELAY_DIR/tunnel.log
StandardError=append:$RELAY_DIR/tunnel.log
[Install]
WantedBy=multi-user.target
EOF
grep ExecStart /etc/systemd/system/lanremote-tunnel.service | sed 's/^/ /'
echo
echo "===== 2. 中转长轮询 25 秒 -> 15 秒 ====="
UNIT=/etc/systemd/system/lanremote-relay.service
if grep -q 'RELAY_POLL' "$UNIT"; then
sed -i 's/Environment=RELAY_POLL=.*/Environment=RELAY_POLL=15/' "$UNIT"
else
sed -i '/Environment=RELAY_DATA/a Environment=RELAY_POLL=15' "$UNIT"
fi
grep 'RELAY_POLL' "$UNIT" | sed 's/^/ /'
echo
echo "===== 3. 重启 ====="
systemctl stop lanremote-tunnel 2>/dev/null || true
pkill -f cloudflared 2>/dev/null || true
sleep 3
rm -f "$RELAY_DIR/tunnel.log"
systemctl daemon-reload
systemctl restart lanremote-relay
sleep 3
systemctl start lanremote-tunnel
sleep 30
echo " 中转: $(systemctl is-active lanremote-relay)"
echo " 隧道: $(systemctl is-active lanremote-tunnel)"
echo
echo " 注册的连接:"
grep -c 'Registered tunnel connection' "$RELAY_DIR/tunnel.log" 2>/dev/null | sed 's/^/ /'
grep -oE 'protocol=[a-z0-9]+' "$RELAY_DIR/tunnel.log" 2>/dev/null | sort -u | sed 's/^/ /'
echo
echo "===== 4. 连打 15 次看成功率 ====="
OK=0
for i in $(seq 1 15); do
C=$(timeout 15 curl -4 -s -o /dev/null -w '%{http_code}' \
-H 'User-Agent: LanRemote/1.4.0' \
https://relay.xxmxxs.top/v1/health 2>/dev/null)
[ "$C" = "200" ] && { OK=$((OK + 1)); MARK="✓"; } || MARK="✗"
printf " %2d: %s HTTP %s\n" "$i" "$MARK" "${C:-超时}"
sleep 2
done
echo
echo " 成功 $OK / 15"
if [ "$OK" -ge 13 ]; then
echo " ✓ 稳"
elif [ "$OK" -ge 8 ]; then
echo " ~ 还行,有抖动但可用"
else
echo " ✗ 还是抖"
fi
echo
echo "===== 5. 内存 ====="
free -m | awk 'NR==2{printf " 已用 %s MB / 可用 %s MB\n", $3, $7}'