mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 18:20:43 +00:00
阶段1 网络加速 - 发现隧道在跑 QUIC(ExecStart 丢了 --protocol http2), 实测 QUIC 可用率 48% vs HTTP/2 80%+,是重大性能回退。 恢复后公网延迟从 4141ms 降到 690ms(快 6 倍),可用率 92%。 - 优选 IP 结论:无效。hosts 覆盖确实生效了(日志里连的就是指定 IP), 但落点仍是 lax —— 运营商把所有 Cloudflare anycast 都路由到美西。 已清掉这段无效配置。 - BBR 不可用:设备是自定义内核 6.4.0-rc4-jsbsbxjxh66, 没编 tcp_bbr 模块也没配置项。改用 cubic + 调优: TCP 缓冲 4MB、tcp_fastopen=3、tcp_slow_start_after_idle=0 (长轮询场景关键)、tcp_tw_reuse=1。 阶段2 官网重做 - 拆出独立模块 relay/landing.py(relay.py 已两千多行, 再塞 HTML 没法看) - 信息结构参考成熟产品站:吸顶导航 / Hero / 九宫格功能 / 三步上手 / 下载 / FAQ / 页脚 - 保持白色简洁:底白、浅灰面板、细边框、大量留白 - logo 用内联 SVG(ICO 放 img 里实测是破图) - 管理入口从官网移除(管理不对外开放) 过程中被自己的测试抓到两个 bug: - 模块叫 site.py 会和 Python 标准库重名,import site 拿到的是标准库 - _logo() 里把 % 格式化和字符串拼接混用,直接抛 TypeError
68 lines
2.3 KiB
Bash
68 lines
2.3 KiB
Bash
#!/bin/bash
|
||
# 1) 把官网上的「管理入口」链接删掉(管理不对外开放)
|
||
# 2) 应用优选 IP:把 Cloudflare 隧道域名指到实测最快的边缘 IP
|
||
set -u
|
||
|
||
RELAY_DIR=/root/lanremote-relay
|
||
CONFIG=/etc/cloudflared/config.yml
|
||
|
||
echo "===== 1. 备份原配置 ====="
|
||
cp -f /etc/hosts /root/hosts.bak.$(date +%s) 2>/dev/null || true
|
||
cp -f "$CONFIG" /root/config.yml.bak 2>/dev/null || true
|
||
echo " 已备份 /etc/hosts 和 config.yml"
|
||
|
||
echo
|
||
echo "===== 2. 应用优选 IP(写 /etc/hosts 覆盖 GeoDNS)====="
|
||
# 从探测结果里取最快的两个
|
||
BEST=$(head -2 /root/cf_best.txt 2>/dev/null | awk '{print $1}')
|
||
echo " 最快的 IP: $BEST"
|
||
|
||
# 清掉之前加过的
|
||
sed -i '/argotunnel.com/d' /etc/hosts
|
||
|
||
FIRST=$(echo "$BEST" | head -1)
|
||
SECOND=$(echo "$BEST" | tail -1)
|
||
{
|
||
echo ""
|
||
echo "# ykxmz:优选 Cloudflare 隧道边缘(覆盖 GeoDNS,实测延迟更低)"
|
||
echo "$FIRST region1.v2.argotunnel.com"
|
||
echo "$SECOND region2.v2.argotunnel.com"
|
||
echo "$FIRST region1.v2.argotunnel.com"
|
||
echo "$SECOND region2.v2.argotunnel.com"
|
||
} >> /etc/hosts
|
||
|
||
echo " /etc/hosts 现在有:"
|
||
grep argotunnel /etc/hosts | sed 's/^/ /'
|
||
|
||
echo
|
||
echo "===== 3. 确认解析结果变了 ====="
|
||
getent hosts region1.v2.argotunnel.com | head -3 | sed 's/^/ region1 -> /'
|
||
getent hosts region2.v2.argotunnel.com | head -3 | sed 's/^/ region2 -> /'
|
||
|
||
echo
|
||
echo "===== 4. 重启隧道 ====="
|
||
systemctl restart lanremote-tunnel
|
||
sleep 35
|
||
echo " 连接数: $(curl -s --max-time 5 http://127.0.0.1:20241/metrics 2>/dev/null | grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}')"
|
||
echo " 落点:"
|
||
grep -oE 'location=[a-z0-9]+' "$RELAY_DIR/tunnel.log" 2>/dev/null | tail -3 | sed 's/^/ /'
|
||
|
||
echo
|
||
echo "===== 5. 公网延迟对比(20 次)====="
|
||
ok=0; total=0
|
||
for i in $(seq 1 20); do
|
||
t=$(curl -s -o /dev/null -w '%{time_total}' --max-time 15 \
|
||
-H 'User-Agent: LanRemote/1.4.0' https://relay.xxmxxs.top/v1/health 2>/dev/null)
|
||
c=$(curl -s -o /dev/null -w '%{http_code}' --max-time 15 \
|
||
-H 'User-Agent: LanRemote/1.4.0' https://relay.xxmxxs.top/v1/health 2>/dev/null)
|
||
if [ "$c" = "200" ]; then
|
||
ok=$((ok+1))
|
||
printf " %2d: %s 秒\n" "$i" "$t"
|
||
else
|
||
printf " %2d: 失败\n" "$i"
|
||
fi
|
||
total=$((total+1))
|
||
sleep 1
|
||
done
|
||
echo " 可用 $ok/$total"
|