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 + 鍙岃繛鎺?
鏂囨。
- 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
This commit is contained in:
xmz7891
2026-10-06 19:01:05 +08:00
commit b705216e4a
3195 changed files with 203292 additions and 0 deletions
+110
View File
@@ -0,0 +1,110 @@
#!/bin/bash
# 决定性对比:找出最能扛的隧道配置。
#
# 现状:http2 + ha=2 大约 60~75% 可用。剩下 25% 失败的原因是
# 到 Cloudflare 美西边缘(sjc/lax)的国际链路丢包。
#
# 单协议单通道扛不住,那就试三套:
# A) http2 + ha=2 现状
# B) http2 + ha=4 TCP 下多连接不像 UDP 那样互相挤
# C) http2 ha=1 + quic ha=1 两个进程、两种协议同时挂着
# —— Cloudflare 会在所有连接间分发请求,
# 哪个协议当下能通就走哪个
set -u
URL=https://relay.xxmxxs.top
RELAY_DIR=/root/lanremote-relay
UNIT=/etc/systemd/system/lanremote-tunnel.service
stop_all() {
systemctl stop lanremote-tunnel 2>/dev/null || true
systemctl stop lanremote-tunnel-quic 2>/dev/null || true
pkill -f cloudflared 2>/dev/null || true
sleep 3
}
write_unit() {
local name="$1" exec_args="$2"
cat > "/etc/systemd/system/$name.service" <<EOF
[Unit]
Description=LanRemote 隧道($name)
After=network-online.target lanremote-relay.service
Wants=network-online.target lanremote-relay.service
[Service]
Type=simple
ExecStart=/usr/local/bin/cloudflared tunnel $exec_args
Restart=always
RestartSec=5
MemoryMax=160M
StandardOutput=append:/root/lanremote-relay/tunnel.log
StandardError=append:/root/lanremote-relay/tunnel.log
[Install]
WantedBy=multi-user.target
EOF
}
measure() {
local label="$1"
local ok=0 bad=0 i code
for i in $(seq 1 40); do
code=$(timeout 12 curl -4 -s -o /dev/null -w '%{http_code}' \
-H 'User-Agent: LanRemote/1.4.0' "$URL/v1/health" 2>/dev/null)
code=${code:-000}
[ "$code" = "200" ] && ok=$((ok + 1)) || bad=$((bad + 1))
sleep 2
done
local conns
conns=$(curl -s --max-time 5 http://127.0.0.1:20241/metrics 2>/dev/null \
| grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}')
local pct=$((ok * 100 / (ok + bad)))
printf " >>> %-18s 可用 %2d/%2d (%d%%) 连接数=%s\n" \
"$label" "$ok" "$((ok + bad))" "$pct" "${conns:-?}"
echo "$label|$pct|${conns:-0}" >> /root/net_ab.txt
return 0
}
: > /root/net_ab.txt
CFG="--no-autoupdate --edge-ip-version 4 --retries 5 --config /root/.cloudflared/config.yml run lanremote"
echo "===== A) http2 + ha=2(现状)====="
stop_all
: > "$RELAY_DIR/tunnel.log"
write_unit lanremote-tunnel "$CFG --protocol http2 --ha-connections 2"
systemctl daemon-reload
systemctl start lanremote-tunnel
echo " 等 40 秒…"; sleep 40
measure "http2 ha=2"
echo
echo "===== B) http2 + ha=4 ====="
stop_all
: > "$RELAY_DIR/tunnel.log"
write_unit lanremote-tunnel "$CFG --protocol http2 --ha-connections 4"
systemctl daemon-reload
systemctl start lanremote-tunnel
echo " 等 40 秒…"; sleep 40
measure "http2 ha=4"
echo
echo "===== C) http2 ha=1 + quic ha=1(双进程双协议)====="
stop_all
: > "$RELAY_DIR/tunnel.log"
write_unit lanremote-tunnel "$CFG --protocol http2 --ha-connections 1"
write_unit lanremote-tunnel-quic "$CFG --protocol quic --ha-connections 1"
systemctl daemon-reload
systemctl start lanremote-tunnel
systemctl start lanremote-tunnel-quic
echo " 等 50 秒…"; sleep 50
measure "http2+quic 双协议"
echo
echo "===== 汇总 ====="
printf " %-20s %s\n" "配置" "可用率"
while IFS='|' read -r label pct conns; do
printf " %-20s %s%% (连接 %s)\n" "$label" "$pct" "$conns"
done < /root/net_ab.txt
echo
best=$(sort -t'|' -k2 -rn /root/net_ab.txt | head -1 | cut -d'|' -f1)
echo " 最优:$best"