v2box 0.3.1__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {v2box-0.3.1 → v2box-0.3.2}/PKG-INFO +1 -1
- {v2box-0.3.1 → v2box-0.3.2}/pyproject.toml +1 -1
- {v2box-0.3.1 → v2box-0.3.2}/v2box/__init__.py +1 -1
- {v2box-0.3.1 → v2box-0.3.2}/v2box/cli/main.py +5 -2
- {v2box-0.3.1 → v2box-0.3.2}/v2box/core/testing.py +25 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box.egg-info/PKG-INFO +1 -1
- {v2box-0.3.1 → v2box-0.3.2}/README.md +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/setup.cfg +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/cli/__init__.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/core/__init__.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/core/config.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/core/link_builder.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/core/server_config.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/core/service.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/core/store.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/core/subscription.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/parsers/__init__.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/parsers/hysteria2.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/parsers/shadowsocks.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/parsers/socks.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/parsers/trojan.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/parsers/vless.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box/parsers/vmess.py +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box.egg-info/SOURCES.txt +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box.egg-info/dependency_links.txt +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box.egg-info/entry_points.txt +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box.egg-info/requires.txt +0 -0
- {v2box-0.3.1 → v2box-0.3.2}/v2box.egg-info/top_level.txt +0 -0
|
@@ -551,10 +551,13 @@ def cmd_status():
|
|
|
551
551
|
if use_lan:
|
|
552
552
|
console.print("[green]✓[/green] 局域网代理已开启")
|
|
553
553
|
|
|
554
|
-
# Clash API
|
|
555
|
-
from v2box.core.testing import is_clash_api_available
|
|
554
|
+
# Clash API + 实时节点查询
|
|
555
|
+
from v2box.core.testing import is_clash_api_available, get_current_node_via_api
|
|
556
556
|
if is_clash_api_available():
|
|
557
557
|
console.print("[green]✓[/green] Clash API 可用 (127.0.0.1:9090)")
|
|
558
|
+
current = get_current_node_via_api()
|
|
559
|
+
if current:
|
|
560
|
+
console.print(f"[bold green]当前连接:[/bold green] {current['now']}")
|
|
558
561
|
elif is_active:
|
|
559
562
|
console.print("[yellow]⚠[/yellow] Clash API 不可用")
|
|
560
563
|
|
|
@@ -129,3 +129,28 @@ def is_clash_api_available() -> bool:
|
|
|
129
129
|
"""检查 Clash API 是否可用。"""
|
|
130
130
|
result = _api_request("/version", timeout=2)
|
|
131
131
|
return result is not None
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def get_current_node_via_api() -> dict | None:
|
|
135
|
+
"""通过 Clash API 查询当前生效的节点信息。
|
|
136
|
+
|
|
137
|
+
会自动解析嵌套选择器(proxy -> auto -> 实际节点)。
|
|
138
|
+
|
|
139
|
+
Returns:
|
|
140
|
+
{"now": "实际节点名", "mode": "auto 或 manual"}
|
|
141
|
+
失败返回 None
|
|
142
|
+
"""
|
|
143
|
+
result = _api_request("/proxies/proxy", timeout=3)
|
|
144
|
+
if not result or "now" not in result:
|
|
145
|
+
return None
|
|
146
|
+
|
|
147
|
+
selected = result["now"]
|
|
148
|
+
|
|
149
|
+
# 若 proxy 选择器指向 auto(urltest 组),再查一层获取实际节点
|
|
150
|
+
if selected == "auto":
|
|
151
|
+
auto_result = _api_request("/proxies/auto", timeout=3)
|
|
152
|
+
if auto_result and "now" in auto_result:
|
|
153
|
+
return {"now": auto_result["now"], "mode": "auto"}
|
|
154
|
+
return {"now": "auto (未知)", "mode": "auto"}
|
|
155
|
+
|
|
156
|
+
return {"now": selected, "mode": "manual"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|