mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 20:40:43 +00:00
琚帶绔?- 淇 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 + 鍙岃繛鎺? 鏂囨。 - 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
96 lines
3.2 KiB
Bash
96 lines
3.2 KiB
Bash
#!/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)"
|