v2box 0.3.2__tar.gz → 0.3.3__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.
Files changed (28) hide show
  1. {v2box-0.3.2 → v2box-0.3.3}/PKG-INFO +14 -1
  2. {v2box-0.3.2 → v2box-0.3.3}/README.md +13 -0
  3. {v2box-0.3.2 → v2box-0.3.3}/pyproject.toml +1 -1
  4. {v2box-0.3.2 → v2box-0.3.3}/setup.cfg +0 -0
  5. {v2box-0.3.2 → v2box-0.3.3}/v2box/__init__.py +1 -1
  6. {v2box-0.3.2 → v2box-0.3.3}/v2box/cli/__init__.py +0 -0
  7. {v2box-0.3.2 → v2box-0.3.3}/v2box/cli/main.py +4 -2
  8. {v2box-0.3.2 → v2box-0.3.3}/v2box/core/__init__.py +0 -0
  9. {v2box-0.3.2 → v2box-0.3.3}/v2box/core/config.py +17 -4
  10. {v2box-0.3.2 → v2box-0.3.3}/v2box/core/link_builder.py +0 -0
  11. {v2box-0.3.2 → v2box-0.3.3}/v2box/core/server_config.py +0 -0
  12. {v2box-0.3.2 → v2box-0.3.3}/v2box/core/service.py +26 -6
  13. {v2box-0.3.2 → v2box-0.3.3}/v2box/core/store.py +0 -0
  14. {v2box-0.3.2 → v2box-0.3.3}/v2box/core/subscription.py +0 -0
  15. {v2box-0.3.2 → v2box-0.3.3}/v2box/core/testing.py +0 -0
  16. {v2box-0.3.2 → v2box-0.3.3}/v2box/parsers/__init__.py +0 -0
  17. {v2box-0.3.2 → v2box-0.3.3}/v2box/parsers/hysteria2.py +0 -0
  18. {v2box-0.3.2 → v2box-0.3.3}/v2box/parsers/shadowsocks.py +0 -0
  19. {v2box-0.3.2 → v2box-0.3.3}/v2box/parsers/socks.py +0 -0
  20. {v2box-0.3.2 → v2box-0.3.3}/v2box/parsers/trojan.py +0 -0
  21. {v2box-0.3.2 → v2box-0.3.3}/v2box/parsers/vless.py +0 -0
  22. {v2box-0.3.2 → v2box-0.3.3}/v2box/parsers/vmess.py +0 -0
  23. {v2box-0.3.2 → v2box-0.3.3}/v2box.egg-info/PKG-INFO +14 -1
  24. {v2box-0.3.2 → v2box-0.3.3}/v2box.egg-info/SOURCES.txt +0 -0
  25. {v2box-0.3.2 → v2box-0.3.3}/v2box.egg-info/dependency_links.txt +0 -0
  26. {v2box-0.3.2 → v2box-0.3.3}/v2box.egg-info/entry_points.txt +0 -0
  27. {v2box-0.3.2 → v2box-0.3.3}/v2box.egg-info/requires.txt +0 -0
  28. {v2box-0.3.2 → v2box-0.3.3}/v2box.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: v2box
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: 一键将代理节点链接导入 sing-box,轻松管理、测速、切换节点
5
5
  Author: v2box contributors
6
6
  License-Expression: MIT
@@ -168,6 +168,9 @@ v2box apply --no-tun # 不使用 TUN 模式(仅 HTTP/SOCKS 代理)
168
168
  v2box apply --lan # 开启局域网代理
169
169
  v2box apply --lan -p 7890 # 局域网代理 + 自定义端口
170
170
  v2box apply --no-lan # 关闭局域网代理
171
+
172
+ # 指定规则集下载出站(默认 direct,手动模式下使用选中节点)
173
+ v2box apply --download-detour "节点名"
171
174
  ```
172
175
 
173
176
  ### `v2box start / stop / restart` — 服务管理
@@ -473,6 +476,16 @@ v2box apply && v2box restart
473
476
  **Q: 如何导入 socks:// 链接?**
474
477
  > 直接用 `v2box add "socks://..."` 导入,支持 `socks://` 和 `socks5://` 两种前缀。
475
478
 
479
+ **Q: 为什么 `v2box start` 显示成功,但 `v2box status` 提示服务未运行 / Clash API 不可用?**
480
+ > 常见于 sing-box 1.8+ 版本。启动时 sing-box 必须下载 `geoip-cn` / `geosite-cn` 规则集,但旧版 v2box 把 `download_detour` 设为 `proxy`,导致启动时就要依赖代理下载,而代理本身又依赖规则集,形成循环(鸡生蛋)。
481
+ >
482
+ > v2box 现在默认使用 `direct` 下载规则集(手动模式下使用你选中的节点),并启用 `experimental.cache_file` 缓存已下载规则。若你的网络环境 `direct` 无法访问 GitHub raw,可以指定一个能访问的节点:
483
+ > ```bash
484
+ > v2box apply --download-detour "节点名"
485
+ > v2box restart
486
+ > ```
487
+ > 同时 `v2box start` 现在会真正检测服务是否保持运行,失败时直接打印 `systemctl status` 日志,方便定位问题。
488
+
476
489
  ---
477
490
 
478
491
  ## 📄 License
@@ -149,6 +149,9 @@ v2box apply --no-tun # 不使用 TUN 模式(仅 HTTP/SOCKS 代理)
149
149
  v2box apply --lan # 开启局域网代理
150
150
  v2box apply --lan -p 7890 # 局域网代理 + 自定义端口
151
151
  v2box apply --no-lan # 关闭局域网代理
152
+
153
+ # 指定规则集下载出站(默认 direct,手动模式下使用选中节点)
154
+ v2box apply --download-detour "节点名"
152
155
  ```
153
156
 
154
157
  ### `v2box start / stop / restart` — 服务管理
@@ -454,6 +457,16 @@ v2box apply && v2box restart
454
457
  **Q: 如何导入 socks:// 链接?**
455
458
  > 直接用 `v2box add "socks://..."` 导入,支持 `socks://` 和 `socks5://` 两种前缀。
456
459
 
460
+ **Q: 为什么 `v2box start` 显示成功,但 `v2box status` 提示服务未运行 / Clash API 不可用?**
461
+ > 常见于 sing-box 1.8+ 版本。启动时 sing-box 必须下载 `geoip-cn` / `geosite-cn` 规则集,但旧版 v2box 把 `download_detour` 设为 `proxy`,导致启动时就要依赖代理下载,而代理本身又依赖规则集,形成循环(鸡生蛋)。
462
+ >
463
+ > v2box 现在默认使用 `direct` 下载规则集(手动模式下使用你选中的节点),并启用 `experimental.cache_file` 缓存已下载规则。若你的网络环境 `direct` 无法访问 GitHub raw,可以指定一个能访问的节点:
464
+ > ```bash
465
+ > v2box apply --download-detour "节点名"
466
+ > v2box restart
467
+ > ```
468
+ > 同时 `v2box start` 现在会真正检测服务是否保持运行,失败时直接打印 `systemctl status` 日志,方便定位问题。
469
+
457
470
  ---
458
471
 
459
472
  ## 📄 License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "v2box"
7
- version = "0.3.2"
7
+ version = "0.3.3"
8
8
  description = "一键将代理节点链接导入 sing-box,轻松管理、测速、切换节点"
9
9
  readme = "README.md"
10
10
  license = "MIT"
File without changes
@@ -1,3 +1,3 @@
1
1
  """v2box - 一键将代理节点链接导入 sing-box,轻松管理、测速、切换节点"""
2
2
 
3
- __version__ = "0.3.2"
3
+ __version__ = "0.3.3"
File without changes
@@ -397,7 +397,8 @@ def cmd_auto():
397
397
  @click.option("--lan", is_flag=True, default=None, help="开启局域网代理(监听 0.0.0.0)")
398
398
  @click.option("--no-lan", is_flag=True, default=None, help="关闭局域网代理(仅本机)")
399
399
  @click.option("-p", "--port", "listen_port", type=int, default=None, help="代理监听端口")
400
- def cmd_apply(output, dry_run, no_tun, lan, no_lan, listen_port):
400
+ @click.option("--download-detour", "download_detour", default=None, help="规则集下载出站,如 direct 或节点名(默认 auto/direct)")
401
+ def cmd_apply(output, dry_run, no_tun, lan, no_lan, listen_port, download_detour):
401
402
  """根据已导入的节点生成并应用 sing-box 配置。
402
403
 
403
404
  \b
@@ -429,7 +430,8 @@ def cmd_apply(output, dry_run, no_tun, lan, no_lan, listen_port):
429
430
  use_port = listen_port or state.get("port", MIXED_LISTEN_PORT)
430
431
 
431
432
  config = build_config(nodes, mode=mode, selected=selected,
432
- lan=use_lan, port=use_port)
433
+ lan=use_lan, port=use_port,
434
+ download_detour=download_detour)
433
435
 
434
436
  # 移除 TUN
435
437
  if no_tun:
File without changes
@@ -12,7 +12,8 @@ CLASH_API_SECRET = "v2box"
12
12
 
13
13
  def build_config(outbounds: list[dict], mode: str = "auto",
14
14
  selected: str | None = None, lan: bool = False,
15
- port: int = MIXED_LISTEN_PORT) -> dict:
15
+ port: int = MIXED_LISTEN_PORT,
16
+ download_detour: str | None = None) -> dict:
16
17
  """根据节点列表生成完整 sing-box 配置。
17
18
 
18
19
  Args:
@@ -26,6 +27,15 @@ def build_config(outbounds: list[dict], mode: str = "auto",
26
27
  outbounds = [{k: v for k, v in o.items() if not k.startswith("_")} for o in outbounds]
27
28
  tags = [o["tag"] for o in outbounds]
28
29
 
30
+ # 规则集下载路径:默认 direct 避免启动时依赖 proxy 造成循环依赖;
31
+ # 手动模式下优先用用户选中的节点,确保能穿过 GFW 拉取规则集。
32
+ if download_detour:
33
+ detour = download_detour
34
+ elif mode == "manual" and selected and selected in tags:
35
+ detour = selected
36
+ else:
37
+ detour = "direct"
38
+
29
39
  # urltest 自动选择组
30
40
  urltest_group = {
31
41
  "type": "urltest",
@@ -115,23 +125,26 @@ def build_config(outbounds: list[dict], mode: str = "auto",
115
125
  "type": "remote",
116
126
  "format": "binary",
117
127
  "url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs",
118
- "download_detour": "proxy",
128
+ "download_detour": detour,
119
129
  },
120
130
  {
121
131
  "tag": "geosite-cn",
122
132
  "type": "remote",
123
133
  "format": "binary",
124
134
  "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs",
125
- "download_detour": "proxy",
135
+ "download_detour": detour,
126
136
  },
127
137
  ],
128
138
  "final": "proxy",
129
139
  },
130
140
  "experimental": {
141
+ "cache_file": {
142
+ "enabled": True,
143
+ },
131
144
  "clash_api": {
132
145
  "external_controller": f"127.0.0.1:{CLASH_API_PORT}",
133
146
  "secret": CLASH_API_SECRET,
134
- }
147
+ },
135
148
  },
136
149
  }
137
150
  return config
File without changes
File without changes
@@ -50,9 +50,20 @@ def check_config(config_path: str = "/etc/sing-box/config.json") -> tuple[bool,
50
50
  def start() -> tuple[bool, str]:
51
51
  """启动 sing-box 服务。"""
52
52
  result = _run(["sudo", "systemctl", "start", "sing-box"])
53
- if result.returncode == 0:
54
- return True, "sing-box 已启动"
55
- return False, result.stderr.strip()
53
+ if result.returncode != 0:
54
+ return False, result.stderr.strip()
55
+
56
+ # 启动命令返回 0 不代表服务真的在运行,systemd 启动后进程可能立即失败
57
+ import time
58
+ for _ in range(5):
59
+ time.sleep(0.5)
60
+ is_active, detail = status()
61
+ if is_active:
62
+ return True, "sing-box 已启动"
63
+
64
+ # 提取失败原因
65
+ detail = _run(["systemctl", "status", "sing-box", "--no-pager", "-l"]).stdout.strip()
66
+ return False, f"服务启动后未能保持运行,请检查日志:\n{detail}"
56
67
 
57
68
 
58
69
  def stop() -> tuple[bool, str]:
@@ -66,9 +77,18 @@ def stop() -> tuple[bool, str]:
66
77
  def restart() -> tuple[bool, str]:
67
78
  """重启 sing-box 服务。"""
68
79
  result = _run(["sudo", "systemctl", "restart", "sing-box"])
69
- if result.returncode == 0:
70
- return True, "sing-box 已重启"
71
- return False, result.stderr.strip()
80
+ if result.returncode != 0:
81
+ return False, result.stderr.strip()
82
+
83
+ import time
84
+ for _ in range(5):
85
+ time.sleep(0.5)
86
+ is_active, detail = status()
87
+ if is_active:
88
+ return True, "sing-box 已重启"
89
+
90
+ detail = _run(["systemctl", "status", "sing-box", "--no-pager", "-l"]).stdout.strip()
91
+ return False, f"服务重启后未能保持运行,请检查日志:\n{detail}"
72
92
 
73
93
 
74
94
  def status() -> tuple[bool, str]:
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: v2box
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: 一键将代理节点链接导入 sing-box,轻松管理、测速、切换节点
5
5
  Author: v2box contributors
6
6
  License-Expression: MIT
@@ -168,6 +168,9 @@ v2box apply --no-tun # 不使用 TUN 模式(仅 HTTP/SOCKS 代理)
168
168
  v2box apply --lan # 开启局域网代理
169
169
  v2box apply --lan -p 7890 # 局域网代理 + 自定义端口
170
170
  v2box apply --no-lan # 关闭局域网代理
171
+
172
+ # 指定规则集下载出站(默认 direct,手动模式下使用选中节点)
173
+ v2box apply --download-detour "节点名"
171
174
  ```
172
175
 
173
176
  ### `v2box start / stop / restart` — 服务管理
@@ -473,6 +476,16 @@ v2box apply && v2box restart
473
476
  **Q: 如何导入 socks:// 链接?**
474
477
  > 直接用 `v2box add "socks://..."` 导入,支持 `socks://` 和 `socks5://` 两种前缀。
475
478
 
479
+ **Q: 为什么 `v2box start` 显示成功,但 `v2box status` 提示服务未运行 / Clash API 不可用?**
480
+ > 常见于 sing-box 1.8+ 版本。启动时 sing-box 必须下载 `geoip-cn` / `geosite-cn` 规则集,但旧版 v2box 把 `download_detour` 设为 `proxy`,导致启动时就要依赖代理下载,而代理本身又依赖规则集,形成循环(鸡生蛋)。
481
+ >
482
+ > v2box 现在默认使用 `direct` 下载规则集(手动模式下使用你选中的节点),并启用 `experimental.cache_file` 缓存已下载规则。若你的网络环境 `direct` 无法访问 GitHub raw,可以指定一个能访问的节点:
483
+ > ```bash
484
+ > v2box apply --download-detour "节点名"
485
+ > v2box restart
486
+ > ```
487
+ > 同时 `v2box start` 现在会真正检测服务是否保持运行,失败时直接打印 `systemctl status` 日志,方便定位问题。
488
+
476
489
  ---
477
490
 
478
491
  ## 📄 License
File without changes
File without changes