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

88 lines
2.9 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
# HTTP/2 下再比一次 ha=1 vs ha=2。
#
# 观察:
# http2 + ha=1 跑 3 分钟 —— 断开 0 次、拨号失败 0 次(连接本身很稳),
# 但单个请求仍有 35% 失败(530 / 000)。
#
# TCP 的重传比较慢,单条连接一旦卡住,请求就干等。
# 所以想验证:两条 HTTP/2 连接能不能互补
# (UDP 时代 ha=2 是互相拖累,TCP 下可能不一样)。
set -u
UNIT=/etc/systemd/system/lanremote-tunnel.service
URL=https://relay.xxmxxs.top
RELAY_DIR=/root/lanremote-relay
run_case() {
local conns="$1" label="$2"
cat > "$UNIT" <<EOF
[Unit]
Description=LanRemote Cloudflare 具名隧道
After=network-online.target lanremote-relay.service
Wants=network-online.target lanremote-relay.service
[Service]
Type=simple
ExecStart=/usr/local/bin/cloudflared tunnel --no-autoupdate --protocol http2 --edge-ip-version 4 --ha-connections $conns --retries 5 --config /root/.cloudflared/config.yml run lanremote
Restart=always
RestartSec=5
MemoryMax=128M
StandardOutput=append:/root/lanremote-relay/tunnel.log
StandardError=append:/root/lanremote-relay/tunnel.log
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl stop lanremote-tunnel 2>/dev/null || true
pkill -f cloudflared 2>/dev/null || true
sleep 3
: > "$RELAY_DIR/tunnel.log"
systemctl start lanremote-tunnel
echo "===== $label(ha-connections=$conns)====="
echo " 等 40 秒建连…"
sleep 40
local ok=0 bad=0 i code
for i in $(seq 1 40); 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}
[ "$code" = "200" ] && ok=$((ok + 1)) || bad=$((bad + 1))
sleep 3
done
local used drops dials
used=$(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 " >>> %-10s 可用 %2d/%2d (%d%%) 注册 %s 断开 %s 拨号失败 %s\n" \
"$label" "$ok" "$((ok + bad))" "$pct" "$used" "$drops" "$dials"
echo "$conns|$label|$pct|$used|$drops|$dials" >> /root/ha_ab.txt
sleep 2
}
: > /root/ha_ab.txt
run_case 1 "ha=1"
run_case 2 "ha=2"
echo
echo "===== 汇总 ====="
printf " %-16s %-8s %-8s %-8s %s\n" "配置" "可用率" "注册" "断开" "拨号失败"
while IFS='|' read -r c label pct used drops dials; do
printf " %-16s %-8s %-8s %-8s %s\n" "$label" "$pct%" "$used" "$drops" "$dials"
done < /root/ha_ab.txt
A=$(grep '|ha=1|' /root/ha_ab.txt | cut -d'|' -f3)
B=$(grep '|ha=2|' /root/ha_ab.txt | cut -d'|' -f3)
echo
echo " ha=1 $A% vs ha=2 $B%"
if [ "$B" -gt "$A" ]; then
echo " -> ha=2 更好"
else
echo " -> ha=1 更好(或持平)"
fi