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

89 lines
3.0 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
# 当前链路严重退化(18 次断开 / 20 次 quic 错误 / 公网 0/10)。
# 试试 ha-connections=1:少一条并发 QUIC 就少一份争抢。
set -u
RELAY_DIR=/root/lanremote-relay
UNIT=/etc/systemd/system/lanremote-tunnel.service
URL=https://relay.xxmxxs.top
echo "===== 1. 改成 ha=1 ====="
cat > "$UNIT" <<'EOF'
[Unit]
Description=LanRemote Cloudflare 具名隧道
After=network-online.target lanremote-relay.service
Wants=network-online.target lanremote-relay.service
[Service]
Type=simple
# 协议:必须 QUIC(这条线路挡了 HTTP/2 的 TCP 7844)
# 连接数:1
# 实测 4 条并发 QUIC 握手互相挤(只成功 1 条);
# 链路退化时 2 条也会有一条一直失败重试、拖累另一条。
# 1 条最稳。丢冗余换稳定 —— 看门狗会在断的时候重启。
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 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 start lanremote-tunnel
echo " 已启动,等 40 秒建连接…"
sleep 40
echo
echo "===== 2. 连接情况 ====="
echo -n " ha_connections = "
curl -s --max-time 5 http://127.0.0.1:20241/metrics 2>/dev/null \
| grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}'
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
echo "===== 3. 公网连打 15 次 ====="
OK=0
for i in $(seq 1 15); do
C=$(timeout 20 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)); M="✓"; } || M="✗"
printf " %2d: %s %s\n" "$i" "$M" "${C:-超时}"
sleep 2
done
PCT=$((OK * 100 / 15))
echo " 公网 $OK / 15 ($PCT%)"
echo
echo "===== 4. 再等 60 秒看长稳不稳 ====="
sleep 60
OK2=0
for i in $(seq 1 10); do
C=$(timeout 20 curl -4 -s -o /dev/null -w '%{http_code}' \
-H 'User-Agent: LanRemote/1.4.0' "$URL/v1/health" 2>/dev/null)
[ "$C" = "200" ] && OK2=$((OK2+1))
sleep 3
done
echo " 第二轮 $OK2 / 10"
echo -n " ha_connections = "
curl -s --max-time 5 http://127.0.0.1:20241/metrics 2>/dev/null \
| grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}'
echo
echo "===== 5. 结论 ====="
echo " ha=1: 第一轮 $OK/15,第二轮 $OK2/10"
if [ "$OK" -ge 12 ] || [ "$OK2" -ge 8 ]; then
echo " ✓ 比 ha=2 好,定 ha=1"
else
echo " ✗ 还是不行 —— 这是链路本身的问题(运营商/信号),"
echo " 不是配置能救的。看门狗会持续重启。"
fi