Files
ykxmz/_build/retest_protocol.sh
T
xmz7891 b705216e4a ykxmz 1.5.0锛氫慨澶嶆墜琛ㄧ TLS 璇佷功鏍¢獙 + MTU 淇缃戠粶绋冲畾鎬?
琚帶绔?- 淇 MTU 闂锛氬す MSS + 璺緞 MTU 鎺㈡祴锛堝叕缃戝彲鐢ㄧ巼 48% -> 100%锛?- 澶嶇敤 HTTP 杩炴帴锛堝厤鎺夋瘡娆℃柊寤?TLS 鐨?30% 鎻℃墜澶辫触锛?- 姣忓垎閽熷洖澶存壘灞€鍩熺綉锛岃嚜鍔ㄥ垏鍥炲揩 400 鍊嶇殑璺緞
- 鐢婚潰蹇冭烦甯э細闈欐鏃剁渷娴侀噺锛屽鎴风浠嶇煡閬撴祦鏄椿鐨?- 閿佸睆鏃剁粰鍑哄彲鎿嶄綔鐨勬彁绀?
鎵嬭〃绔?- 鍐呯疆 GTS Root R4 / GlobalSign Root CA锛屼慨 SSLHandshakeException
- 杩炴帴閿欒缈昏瘧鎴愪汉璇濓紙璇佷功/鏃堕棿/瑙f瀽/瓒呮椂鍒嗗埆鎻愮ず锛?- 缁忎腑杞繛涓婂悗鐢ㄦ湇鍔″櫒鎶ョ殑鍦板潃鍒锋柊宸查厤瀵硅褰?- 鏂板灞€鍩熺綉杩炴帴椤甸潰銆佹湇鍔″櫒寤惰繜妫€娴?
鏈嶅姟鍣ㄧ
- 鏀寔 chunked 璇锋眰浣擄紙淇瘡 16 绉掍竴娆$殑杩炴帴閿欎贡涓庡ぇ闈㈢Н 502锛?- 缃戠粶璋冧紭鑴氭湰 net-tune.sh锛堝紑鏈鸿嚜鍔ㄥ簲鐢級
- 绠$悊椤碉細鎵归噺鍒犻櫎銆佺綉缁滀綋妫€銆佷笅杞藉尯
- 闅ч亾鏀?HTTP/2 + 鍙岃繛鎺?
鏂囨。
- 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
2026-10-06 19:01:05 +08:00

96 lines
3.2 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(UDP)vs HTTP/2(TCP)。
#
# 背景:这条 4G 线路 14 小时里抖了 81 次断开 / 150 次 quic 错误,
# 平均每小时 10 次。每次抖动期间公网都是 1033。
#
# 之前测过 HTTP/2 失败(TCP 7844 握手超时),但那是晚上高峰。
# 现在早上重测一次,两边各跑 3 分钟对比。
set -u
RELAY_DIR=/root/lanremote-relay
URL=https://relay.xxmxxs.top
probe() {
local label="$1"; shift
local extra="$*"
echo "===== 试 $label ====="
echo " 参数: $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 &
local pid=$!
echo " 等 40 秒建连接…"
sleep 40
local conns
conns=$(grep -c 'Registered tunnel connection' "$RELAY_DIR/tunnel.log" 2>/dev/null || echo 0)
echo " 已注册 $conns 条"
if [ "$conns" = "0" ]; then
echo " 日志里的报错:"
grep -iE 'ERR|failed' "$RELAY_DIR/tunnel.log" | tail -3 | sed 's/^/ /'
fi
local ok=0
for i in $(seq 1 12); do
C=$(timeout 15 curl -4 -s -o /dev/null -w '%{http_code}' \
-H 'User-Agent: LanRemote/1.4.0' "$URL/v1/health" 2>/dev/null)
[ "$C" = "200" ] && ok=$((ok + 1))
sleep 5
done
local drops
drops=$(grep -c 'Connection terminated' "$RELAY_DIR/tunnel.log" 2>/dev/null || echo 0)
local errs
errs=$(grep -c 'Failed to dial' "$RELAY_DIR/tunnel.log" 2>/dev/null || echo 0)
echo " >>> $label: 公网 $ok/12,断开 $drops,重连失败 $errs"
echo "$label|$ok|$conns|$drops|$errs" >> /root/proto_result.txt
kill "$pid" 2>/dev/null || true
sleep 2
echo
}
: > /root/proto_result.txt
probe "QUIC(UDP)" "--ha-connections 1 --retries 5"
probe "HTTP2(TCP)" "--protocol http2 --ha-connections 1 --retries 5"
echo "===== 对比 ====="
printf " %-14s %-8s %-8s %-8s %s\n" "协议" "公网" "注册" "断开" "重试失败"
while IFS='|' read -r label ok conns drops errs; do
printf " %-14s %-8s %-8s %-8s %s\n" "$label" "$ok/12" "$conns" "$drops" "$errs"
done < /root/proto_result.txt
echo
echo "===== 恢复正式配置(QUIC + ha=1)====="
cat > /etc/systemd/system/lanremote-tunnel.service <<'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 --edge-ip-version 4 --ha-connections 1 --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 restart lanremote-tunnel
sleep 30
echo " 隧道: $(systemctl is-active lanremote-tunnel)"
echo " 公网: HTTP $(timeout 15 curl -4 -s -o /dev/null -w '%{http_code}' -H 'User-Agent: LanRemote/1.4.0' $URL/v1/health 2>/dev/null)"