Files
ykxmz/_build/find_cf_edge.sh
T
xmz7891 566d9e384f 阶段1+2:恢复 HTTP/2 加速 + 重做官网
阶段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
2026-10-06 23:53:19 +08:00

108 lines
2.6 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 实测设备到 Cloudflare 各边缘 IP 的延迟,挑最快的做优选 IP。
#
# 原理:
# cloudflared 建隧道时会连 region1.v2.argotunnel.com / region2.v2.argotunnel.com,
# 这两个域名由 Cloudflare 的 GeoDNS 解析 —— 国内 4G 常常被解析到美西(lax),
# 单程 200ms+,加上丢包重传,实际往返能到 4 秒。
#
# 但 Cloudflare 在全球有大量 anycast 边缘 IP,其中不少在亚太(香港/新加坡/
# 东京/首尔)能直连,延迟低得多。做法是:
# 1. 测一批候选 IP 的 TCP 7844(隧道端口)握手延迟
# 2. 挑最快的写进 /etc/hosts,覆盖 GeoDNS 的结果
# 3. 重启隧道,实测隧道往返
set -u
CANDIDATES="
104.16.0.0
104.17.0.0
104.18.0.0
104.19.0.0
104.20.0.0
104.21.0.0
104.22.0.0
104.23.0.0
104.24.0.0
104.25.0.0
104.26.0.0
104.27.0.0
104.16.132.229
104.18.2.0
104.18.3.0
104.18.32.0
104.18.33.0
104.18.34.0
104.18.35.0
104.18.36.0
104.18.37.0
104.18.38.0
104.18.39.0
162.159.192.1
162.159.193.1
162.159.195.1
172.64.0.0
172.64.1.0
172.64.2.0
172.64.3.0
172.64.4.0
172.64.5.0
172.64.6.0
172.64.7.0
172.64.8.0
172.64.9.0
172.64.10.0
172.64.11.0
172.64.12.0
172.64.13.0
172.64.14.0
172.64.15.0
172.64.16.0
172.64.17.0
172.64.18.0
172.64.19.0
172.64.20.0
172.64.21.0
172.64.22.0
172.64.23.0
172.64.24.0
172.64.25.0
172.64.26.0
172.64.27.0
172.64.28.0
172.64.29.0
172.64.30.0
172.64.31.0
"
echo "===== 当前 cloudflared 连的是哪个边缘 ====="
grep -oE 'location=[a-z0-9]+' /root/lanremote-relay/tunnel.log 2>/dev/null | sort | uniq -c | tail -5 | sed 's/^/ /'
echo " 当前 region 域名解析到:"
getent hosts region1.v2.argotunnel.com 2>/dev/null | head -2 | sed 's/^/ /'
getent hosts region2.v2.argotunnel.com 2>/dev/null | head -2 | sed 's/^/ /'
echo
echo "===== 逐个测 TCP 7844 握手延迟(每个 2 次取最快)====="
: > /root/cf_ip_result.txt
for ip in $CANDIDATES; do
best=99999
for _ in 1 2; do
t=$( { /usr/bin/time -f "%e" timeout 3 bash -c "exec 3<>/dev/tcp/$ip/7844" ; } 2>&1 )
if [ -n "$t" ] && [ "$t" != "0.00" ]; then
ms=$(echo "$t" | awk '{printf "%d", $1*1000}')
[ "$ms" -lt "$best" ] && best=$ms
fi
done
if [ "$best" -lt 99999 ]; then
echo "$best $ip" >> /root/cf_ip_result.txt
fi
done
if [ -s /root/cf_ip_result.txt ]; then
echo " 最快的 10 个:"
sort -n /root/cf_ip_result.txt | head -10 | while read ms ip; do
printf " %6s ms %s\n" "$ms" "$ip"
done
else
echo " 一个都没通 —— 7844 可能被运营商封了"
fi