Skip to content

Commit d17cec8

Browse files
committed
fix: render check routes with via notation
1 parent 327b8b1 commit d17cec8

3 files changed

Lines changed: 30 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
历史连接数、出现过的进程列表。`build_report` 输出顶层新增 `history_status`
4242
字段记录是否加载成功、读取到几条事件,便于 JSON 消费方判断;human 视图
4343
在 traffic events 为空时一次性提示用户先跑 `proxyctl traffic watch`
44-
- **`proxyctl check` 连通性面板新增实际线路列** proxy 模式的 URL 探测
45-
会从本地 Mihomo `/connections` 读取该站点实际命中的链路,并显示叶子节点
46-
作为 `线路`;直连探测显示 `direct`,DNS/TCP 探测显示 `-`,拿不到活跃
47-
连接时显示 `?`。JSON 输出中的每个 connectivity row 同步新增 `line`
48-
`route_chain` 字段。
44+
- **`proxyctl check` 连通性面板新增实际路由显示** proxy 模式的 URL 探测
45+
会从本地 Mihomo `/connections` 读取该站点实际命中的链路,并在人类输出中
46+
显示为 `via <group> → <leaf>`;直连探测显示 `via direct`,DNS/TCP 探测
47+
显示 `via -`,拿不到活跃连接时显示 `via ?`。JSON 输出中的每个
48+
connectivity row 同步新增 `line``route_chain` 字段。
4949
- **`proxyctl check` 内置连通性基线新增 OpenAI API 探测。**
5050
默认站点现在包含 `openai``https://api.openai.com/v1/models`),并将
5151
`anthropic` 从根路径改为 `https://api.anthropic.com/v1/models`,让 AI
@@ -58,9 +58,9 @@
5858
现在与位置参数共用 AND + 跨字段独立判定逻辑。多值场景下结果可能比旧版本
5959
更窄(旧 OR → 新 AND),但单值场景下匹配范围反而更宽(不再依赖字段被拼接
6060
的顺序)。脚本里使用 `--query` 的用户请确认这一语义变化。
61-
- **`proxyctl check` 连通性成功行不再重复打印 `via ...`**
62-
成功命中期望代理组时,人类输出只保留 `线路 <leaf>` 列;完整链路仍保留在
63-
JSON 的 `route_chain` 字段中。只有期望组不匹配时才追加错误说明。
61+
- **`proxyctl check` 连通性成功行统一使用 `via ...` 表达**
62+
成功命中期望代理组时,人类输出不再同时显示 `线路 <leaf>` `via ...`
63+
所有连通性行统一保留 `via <route>`。只有期望组不匹配时才追加错误说明。
6464
- **`proxyctl check` 会去重内置插件与用户插件提供的完全相同探测项。**
6565
当旧用户插件仍声明与内置插件相同的 connectivity target 或 outbound probe
6666
时,人类输出不再重复显示同一站点或同一出口 IP;不同 URL 或不同 mode 的

src/proxyctl/check.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,11 @@ def _connectivity_line_value(mode: str) -> str:
159159
return "-"
160160

161161

162-
def _append_line_column(line: str, route_line: str) -> str:
163-
"""Append the observed route line as a stable human column."""
164-
value = route_line or "-"
165-
return f"{line} {DIM}线路{NC} {value:<24s}"
162+
def _append_route_column(line: str, route_line: str,
163+
route_chain: str = "") -> str:
164+
"""Append the observed route in the same style as Mihomo chains."""
165+
value = route_chain or route_line or "-"
166+
return f"{line} {DIM}via{NC} {value:<32s}"
166167

167168

168169
def _dedupe_check_targets(targets: list) -> list:
@@ -1196,11 +1197,11 @@ def _run_test(idx, target):
11961197
route_note = f" {GREEN}{route_msg}{NC}"
11971198
else:
11981199
route_note = f" {RED}{route_msg}{NC}"
1199-
line = _append_line_column(line, route_line)
1200+
line = _append_route_column(line, route_line, route_chain)
12001201
line += route_note
12011202
except Exception as e:
12021203
ok, line = False, f" {RED}{NC} {target.name} error: {e}"
1203-
line = _append_line_column(line, route_line)
1204+
line = _append_route_column(line, route_line, route_chain)
12041205
results[idx] = (line, ok, route_line, route_chain)
12051206
ready[idx].set()
12061207

tests/unit/test_check.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,21 @@ def fake_run(cmd, *args, **kwargs):
120120
assert "http_proxy" not in captured_env
121121

122122

123-
def test_append_line_column_adds_route_line():
124-
line = check._append_line_column(" ✓ google https://x 200", "日本1")
125-
assert "线路" in line
126-
assert "日本1" in line
123+
def test_append_route_column_prefers_route_chain():
124+
line = check._append_route_column(
125+
" ✓ anthropic https://x 401",
126+
"TW-Residential-01",
127+
"claude → TW-Residential-01",
128+
)
129+
assert "via" in line
130+
assert "claude → TW-Residential-01" in line
131+
assert "线路" not in line
132+
133+
134+
def test_append_route_column_falls_back_to_route_line():
135+
line = check._append_route_column(" ✓ baidu https://x 200", "direct")
136+
assert "via" in line
137+
assert "direct" in line
127138

128139

129140
# ────────────────────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)