Files
pangolin/tests/vpn
wangjia a19406d041 feat(test): VPN 黑盒/白盒测试工具 + 索引页 + 链路时序图与阶段拆解
- vpn_test.py(黑盒):站点矩阵连通/延迟(TLS 握手口径)/吞吐,落 tests/vpn/runs/
  并重建 index.html 索引(内嵌 meta、file:// 直开);索引含 cara→LA→Google 时序图
  + 步骤表
- vpn_whitebox.py(白盒):双 IP-echo 判国内是否被隧道 + 五段拆解;经控制面
  /v1/diag/egress 取出海段,自动算「接入段=整轮−出海段」,报告出「阶段拆解」表
  (对应时序图 橙=接入 / 绿=出海)
- tests/vpn/: runs 与生成的 index.html 为本地工件(.gitignore),README 说明用法
- docs/: vpn-testing-research.md(调研)+ vpn-test-plan.md(黑盒/白盒方案)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 14:12:46 +08:00
..

tests/vpn —— VPN 测试产物目录

每次跑 scripts/vpn_test.py(黑盒)会:

  1. 把本次报告写到 runs/<时间>-<主机>.html;
  2. 扫描 runs/ 内嵌的 meta、重建 index.html 索引页(列出历次跑的时间/主机/出口/可达/延迟中位数/下载速度,点行进报告)。

runs/ 与生成的 index.html本地工件,不入 git(见 .gitignore)——换机器跑会从零累积。

怎么跑

# 在「已连 VPN 的机器」上(本机或 ssh 到 cara)
python3 scripts/vpn_test.py                 # 落 tests/vpn/runs/ 并刷新 index.html
python3 scripts/vpn_test.py --no-download    # 跳过吞吐(快)
NODE_IP=103.119.13.48 python3 scripts/vpn_test.py

# 远程在 cara 上跑、把整个 runs 目录拉回本地看索引:
scp scripts/vpn_test.py cara:/tmp/
ssh cara 'python3 /tmp/vpn_test.py --runs-dir /tmp/pg-runs --index /tmp/pg-runs/index.html'
scp -r cara:/tmp/pg-runs/. tests/vpn/runs/      # 再本地重建索引:
python3 -c "import importlib.util as u;s=u.spec_from_file_location('v','scripts/vpn_test.py');m=u.module_from_spec(s);s.loader.exec_module(m);m.regenerate_index('tests/vpn/runs','tests/vpn/index.html')"

open tests/vpn/index.html                    # 看索引(可 file:// 直开,数据内嵌无需 server)

口径

延迟 = TLS 握手耗时(非 IP TTL,非 ping/tcp_connect)。详见 docs/vpn-test-plan.mddocs/vpn-testing-research.md

白盒(下钻链路/出站/DNS 走向)见 scripts/vpn_whitebox.sh(待补)。