#!/bin/bash # 严格验证:chunked 修复之后,稳定性到底改善了没有。 # # 之前(修之前)的实测基线: # QUIC ha=1 48% # HTTP2 ha=1 35~65% # HTTP2 ha=2 60~75% # 长轮询 60 次只成功 18 次(30%),而且是"跑着跑着全挂" # # 现在跑 5 分钟,看: # 1. 公网可用率 # 2. 隧道断开次数 # 3. 日志里还有没有 502 / Unsolicited response set -u RELAY_DIR=/root/lanremote-relay URL=https://relay.xxmxxs.top echo "===== 起点状态 =====" echo " 隧道: $(systemctl is-active lanremote-tunnel)" echo " 连接数: $(curl -s --max-time 5 http://127.0.0.1:20241/metrics | grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}')" # 清空日志,从干净状态开始统计 : > "$RELAY_DIR/tunnel.log" echo " (已清空隧道日志,重新计数)" echo echo "===== 连续探 5 分钟(每 3 秒一次,共 100 次)=====" ok=0; bad=0 for i in $(seq 1 100); do c=$(timeout 12 curl -4 -s -o /dev/null -w '%{http_code}' \ -H 'User-Agent: LanRemote/1.4.0' "$URL/v1/health" 2>/dev/null) c=${c:-000} if [ "$c" = "200" ]; then ok=$((ok + 1)) else bad=$((bad + 1)) printf " [%3ds] 不通 %s\n" "$((i * 3))" "$c" fi sleep 3 done echo echo "===== 结果 =====" echo " 公网可用 $ok/100 = $((ok))%" echo echo " 隧道统计(这 5 分钟内):" echo " 注册 $(grep -c 'Registered tunnel connection' "$RELAY_DIR/tunnel.log" 2>/dev/null || echo 0) 次" echo " 断开 $(grep -c 'Connection terminated' "$RELAY_DIR/tunnel.log" 2>/dev/null || echo 0) 次" echo " Lost edge $(grep -c 'Lost connection with the edge' "$RELAY_DIR/tunnel.log" 2>/dev/null || echo 0) 次" echo " Unsolicited(那条 400 污染)$(grep -c 'Unsolicited response' "$RELAY_DIR/tunnel.log" 2>/dev/null || echo 0) 次" echo " Bad request syntax $(grep -c 'Bad request syntax' "$RELAY_DIR/tunnel.log" 2>/dev/null || echo 0) 次" echo echo " 看门狗这段时间的动作:" tail -5 "$RELAY_DIR/watchdog.log" 2>/dev/null | sed 's/^/ /' echo echo "===== 对比修之前 =====" echo " 修之前:48% ~ 70%(而且长轮询跑几十次就全挂)" echo " 修之后:$ok%" if [ "$ok" -ge 95 ]; then echo " ✓ 达标(≥95%)" elif [ "$ok" -ge 85 ]; then echo " ~ 明显改善" else echo " ✗ 还没解决" fi