Files
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

82 lines
2.7 KiB
Bash
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.
#!/bin/bash
# A/B 对比:QUIC(UDP) vs HTTP/2(TCP)
#
# 背景:
# 隧道日志里全是 QUIC 超时:
# Failed to dial a quic connection ... no recent network activity
# Connection terminated error="control stream error"
# 全是 "Failed to accept QUIC stream"
# 而 cloudflared 自己回退成 protocol=http2 之后**注册成功了**。
# 所以怀疑这条 4G 线路在丢 UDP 包,TCP 反而稳。
#
# 每边跑 90 秒,每 2 秒探一次公网,对比不通率。
set -u
RELAY_DIR=/root/lanremote-relay
URL=https://relay.xxmxxs.top
test_protocol() {
local label="$1"; shift
local extra="$*"
systemctl stop lanremote-tunnel 2>/dev/null || true
pkill -f cloudflared 2>/dev/null || true
sleep 3
: > "$RELAY_DIR/tunnel.log"
# shellcheck disable=SC2086
nohup cloudflared tunnel --no-autoupdate --edge-ip-version 4 $extra \
--config /root/.cloudflared/config.yml run lanremote \
>> "$RELAY_DIR/tunnel.log" 2>&1 &
echo "===== $label($extra)====="
echo " 等 35 秒建连…"
sleep 35
local ok=0 bad=0 i code
for i in $(seq 1 45); do
code=$(timeout 12 curl -4 -s -o /dev/null -w '%{http_code}' \
-H 'User-Agent: LanRemote/1.4.0' "$URL/v1/health" 2>/dev/null)
code=${code:-000}
if [ "$code" = "200" ]; then ok=$((ok + 1)); else bad=$((bad + 1)); fi
sleep 2
done
local conns drops dials
conns=$(grep -c 'Registered tunnel connection' "$RELAY_DIR/tunnel.log" 2>/dev/null || echo 0)
drops=$(grep -c 'Connection terminated' "$RELAY_DIR/tunnel.log" 2>/dev/null || echo 0)
dials=$(grep -c 'Failed to dial' "$RELAY_DIR/tunnel.log" 2>/dev/null || echo 0)
local pct=$((ok * 100 / (ok + bad)))
printf " >>> %-12s 可用 %2d/%2d (%d%%) 注册 %s 次 断开 %s 次 拨号失败 %s 次\n" \
"$label" "$ok" "$((ok + bad))" "$pct" "$conns" "$drops" "$dials"
echo "$label|$pct|$conns|$drops|$dials" >> /root/proto_ab.txt
pkill -f cloudflared 2>/dev/null || true
sleep 2
}
: > /root/proto_ab.txt
test_protocol "QUIC" ""
test_protocol "HTTP2" "--protocol http2"
echo
echo "===== 汇总 ====="
printf " %-8s %-8s %-8s %-8s %s\n" "协议" "可用率" "注册" "断开" "拨号失败"
while IFS='|' read -r label pct conns drops dials; do
printf " %-8s %-8s %-8s %-8s %s\n" "$label" "$pct%" "$conns" "$drops" "$dials"
done < /root/proto_ab.txt
echo
echo "===== 结论 ====="
Q=$(grep '^QUIC' /root/proto_ab.txt | cut -d'|' -f2)
H=$(grep '^HTTP2' /root/proto_ab.txt | cut -d'|' -f2)
echo " QUIC $Q% vs HTTP2 $H%"
if [ "$H" -gt "$Q" ]; then
echo " -> HTTP/2 明显更好,改用它"
elif [ "$Q" -gt "$H" ]; then
echo " -> QUIC 更好,保持"
else
echo " -> 两者差不多"
fi