mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-19 08:20:44 +00:00
ykxmz 1.5.0:修复手表端 TLS 证书校验 + MTU 修复网络稳定性
被控端 - 修复 MTU 问题:夹 MSS + 路径 MTU 探测(公网可用率 48% -> 100%) - 复用 HTTP 连接(免掉每次新建 TLS 的 30% 握手失败) - 每分钟回头找局域网,自动切回快 400 倍的路径 - 画面心跳帧:静止时省流量,客户端仍知道流是活的 - 锁屏时给出可操作的提示 手表端 - 内置 GTS Root R4 / GlobalSign Root CA,修 SSLHandshakeException - 连接错误翻译成人话(证书/时间/解析/超时分别提示) - 经中转连上后用服务器报的地址刷新已配对记录 - 新增局域网连接页面、服务器延迟检测 服务器端 - 支持 chunked 请求体(修每 16 秒一次的连接错乱与大面积 502) - 网络调优脚本 net-tune.sh(开机自动应用) - 管理页:批量删除、网络体检、下载区 - 隧道改 HTTP/2 + 双连接 文档 - 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
#!/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)"
|
||||
Reference in New Issue
Block a user