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

99 lines
3.3 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,并做抗抖动调优。
#
# 实测结论(很明确):
# HTTP/2 走 TCP 7844 -> "TLS handshake with edge ... i/o timeout"
# 这条线路把 TCP 7844 挡了
# QUIC 走 UDP 7844 -> 能连上(虽然偶尔抖)
# 所以**只能用 QUIC**,之前的 502/530 是线路抖动,不是协议选错。
#
# 抗抖动调优:
# 1. --ha-connections 4 同时保持 4 条到边缘的连接(默认值,显式写上)
# 2. --retries 5 连边缘失败时多重试
# 3. 中转的长轮询从 25 秒降到 15 秒
# 长连接更容易被抖动打断;短一点反而更稳,
# 而且断了一条只影响 15 秒的请求,不是 25 秒。
set -u
RELAY_DIR=/root/lanremote-relay
echo "===== 1. 写回 QUIC + 调优参数 ====="
cat > /etc/systemd/system/lanremote-tunnel.service <<EOF
[Unit]
Description=LanRemote Cloudflare 具名隧道
After=network-online.target lanremote-relay.service
Wants=network-online.target
Requires=lanremote-relay.service
[Service]
Type=simple
# 必须用 QUIC(默认):
# 实测这条 4G 线路把 HTTP/2 用的 TCP 7844 挡了
# (TLS handshake timeout),而 QUIC 走 UDP 7844 是通的。
# --ha-connections 4 同时保持 4 条连接,抖掉一条还有别的。
# --retries 5 连不上边缘时多重试几次。
ExecStart=/usr/local/bin/cloudflared tunnel --no-autoupdate --edge-ip-version 4 --ha-connections 4 --retries 5 --config /root/.cloudflared/config.yml run lanremote
Restart=always
RestartSec=5
MemoryMax=128M
StandardOutput=append:$RELAY_DIR/tunnel.log
StandardError=append:$RELAY_DIR/tunnel.log
[Install]
WantedBy=multi-user.target
EOF
grep ExecStart /etc/systemd/system/lanremote-tunnel.service | sed 's/^/ /'
echo
echo "===== 2. 中转长轮询 25 秒 -> 15 秒 ====="
UNIT=/etc/systemd/system/lanremote-relay.service
if grep -q 'RELAY_POLL' "$UNIT"; then
sed -i 's/Environment=RELAY_POLL=.*/Environment=RELAY_POLL=15/' "$UNIT"
else
sed -i '/Environment=RELAY_DATA/a Environment=RELAY_POLL=15' "$UNIT"
fi
grep 'RELAY_POLL' "$UNIT" | sed 's/^/ /'
echo
echo "===== 3. 重启 ====="
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 restart lanremote-relay
sleep 3
systemctl start lanremote-tunnel
sleep 30
echo " 中转: $(systemctl is-active lanremote-relay)"
echo " 隧道: $(systemctl is-active lanremote-tunnel)"
echo
echo " 注册的连接:"
grep -c 'Registered tunnel connection' "$RELAY_DIR/tunnel.log" 2>/dev/null | sed 's/^/ /'
grep -oE 'protocol=[a-z0-9]+' "$RELAY_DIR/tunnel.log" 2>/dev/null | sort -u | sed 's/^/ /'
echo
echo "===== 4. 连打 15 次看成功率 ====="
OK=0
for i in $(seq 1 15); do
C=$(timeout 15 curl -4 -s -o /dev/null -w '%{http_code}' \
-H 'User-Agent: LanRemote/1.4.0' \
https://relay.xxmxxs.top/v1/health 2>/dev/null)
[ "$C" = "200" ] && { OK=$((OK + 1)); MARK="✓"; } || MARK="✗"
printf " %2d: %s HTTP %s\n" "$i" "$MARK" "${C:-超时}"
sleep 2
done
echo
echo " 成功 $OK / 15"
if [ "$OK" -ge 13 ]; then
echo " ✓ 稳"
elif [ "$OK" -ge 8 ]; then
echo " ~ 还行,有抖动但可用"
else
echo " ✗ 还是抖"
fi
echo
echo "===== 5. 内存 ====="
free -m | awk 'NR==2{printf " 已用 %s MB / 可用 %s MB\n", $3, $7}'