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:
xmz7891
2026-10-06 19:01:05 +08:00
commit b62ac865ea
3195 changed files with 203292 additions and 0 deletions
+96
View File
@@ -0,0 +1,96 @@
#!/bin/bash
# 测试 --region:能不能让 cloudflared 连亚洲边缘而不是美西?
#
# 现状:连的是 198.41.x.x,落地 lax01/sjc07(美西),ICMP 199~243ms,
# 丢包 40%,握手经常超时。
# cloudflared 有个 --region 参数("Cloudflare Edge region to connect to")。
# 如果能把落地换到香港/新加坡/东京,延迟和丢包都会好很多。
set -u
URL=https://relay.xxmxxs.top
RELAY_DIR=/root/lanremote-relay
BASE="--no-autoupdate --edge-ip-version 4 --retries 5 --config /root/.cloudflared/config.yml run lanremote"
try_region() {
local region="$1"
local label="$2"
systemctl stop lanremote-tunnel 2>/dev/null || true
pkill -f cloudflared 2>/dev/null || true
sleep 2
: > "$RELAY_DIR/tunnel.log"
if [ -n "$region" ]; then
nohup cloudflared tunnel --region "$region" $BASE \
>> "$RELAY_DIR/tunnel.log" 2>&1 &
else
nohup cloudflared tunnel $BASE >> "$RELAY_DIR/tunnel.log" 2>&1 &
fi
sleep 30
local conns loc proto
conns=$(grep -c 'Registered tunnel connection' "$RELAY_DIR/tunnel.log" 2>/dev/null || echo 0)
loc=$(grep -o 'location=[a-z0-9]*' "$RELAY_DIR/tunnel.log" 2>/dev/null | tail -1)
proto=$(grep -o 'protocol=[a-z0-9]*' "$RELAY_DIR/tunnel.log" 2>/dev/null | tail -1)
printf " %-14s 注册 %-3s %-14s %s\n" "$label" "$conns" "${loc:-?}" "${proto:-?}"
if [ "$conns" = "0" ]; then
echo " 报错:"
grep -iE 'error|fatal|invalid' "$RELAY_DIR/tunnel.log" 2>/dev/null \
| tail -2 | sed 's/^/ /'
fi
# 快速探 10 次
local ok=0
for i in $(seq 1 10); do
c=$(timeout 12 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 2
done
echo " 公网 $ok/10"
echo "$label|$ok|${loc:-?}|$conns" >> /root/region_result.txt
pkill -f cloudflared 2>/dev/null || true
sleep 2
}
: > /root/region_result.txt
echo "===== 各 region 的表现 ====="
try_region "" "默认(global)"
try_region "ap" "ap"
try_region "us" "us"
echo
echo "===== 汇总 ====="
while IFS='|' read -r label ok loc conns; do
printf " %-16s 公网 %s/10 落地=%s 注册=%s\n" "$label" "$ok" "$loc" "$conns"
done < /root/region_result.txt
echo
echo "===== 恢复默认配置 ====="
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 --protocol http2 --ha-connections 2 $BASE
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
systemctl daemon-reload
systemctl start lanremote-tunnel
sleep 30
echo " 隧道: $(systemctl is-active lanremote-tunnel)"
echo " 连接数: $(curl -s --max-time 5 http://127.0.0.1:20241/metrics | grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}')"