v2box 0.3.0__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.0 → v2box-0.3.2}/PKG-INFO +34 -3
- {v2box-0.3.0 → v2box-0.3.2}/README.md +33 -2
- {v2box-0.3.0 → v2box-0.3.2}/pyproject.toml +1 -1
- {v2box-0.3.0 → v2box-0.3.2}/v2box/__init__.py +1 -1
- {v2box-0.3.0 → v2box-0.3.2}/v2box/cli/main.py +51 -14
- {v2box-0.3.0 → v2box-0.3.2}/v2box/core/link_builder.py +23 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/core/server_config.py +81 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/core/testing.py +25 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/parsers/__init__.py +5 -2
- v2box-0.3.2/v2box/parsers/socks.py +73 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box.egg-info/PKG-INFO +34 -3
- {v2box-0.3.0 → v2box-0.3.2}/v2box.egg-info/SOURCES.txt +1 -0
- {v2box-0.3.0 → v2box-0.3.2}/setup.cfg +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/cli/__init__.py +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/core/__init__.py +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/core/config.py +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/core/service.py +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/core/store.py +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/core/subscription.py +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/parsers/hysteria2.py +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/parsers/shadowsocks.py +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/parsers/trojan.py +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/parsers/vless.py +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box/parsers/vmess.py +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box.egg-info/dependency_links.txt +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box.egg-info/entry_points.txt +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/v2box.egg-info/requires.txt +0 -0
- {v2box-0.3.0 → v2box-0.3.2}/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.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: 一键将代理节点链接导入 sing-box,轻松管理、测速、切换节点
|
|
5
5
|
Author: v2box contributors
|
|
6
6
|
License-Expression: MIT
|
|
@@ -27,7 +27,7 @@ Requires-Dist: rich>=13.0
|
|
|
27
27
|
|
|
28
28
|
## ✨ 功能特性
|
|
29
29
|
|
|
30
|
-
- **多协议支持** — VLESS、VMess、Shadowsocks、Trojan、Hysteria2
|
|
30
|
+
- **多协议支持** — VLESS、VMess、Shadowsocks、Trojan、Hysteria2、SOCKS5
|
|
31
31
|
- **一键导入** — 支持单条链接、文件批量导入
|
|
32
32
|
- **订阅管理** — 添加/更新/删除订阅,一键拉取节点,支持 Base64 自动解码
|
|
33
33
|
- **智能去重** — 基于配置内容去重,同名不同配置的节点自动区分
|
|
@@ -37,7 +37,7 @@ Requires-Dist: rich>=13.0
|
|
|
37
37
|
- **服务管理** — 启动、停止、重启 sing-box,一条命令搞定
|
|
38
38
|
- **简洁 CLI** — 命令短小好记,带中文帮助和示例
|
|
39
39
|
- **TUN 模式** — 默认开启全局透明代理(可关闭)
|
|
40
|
-
- **服务端管理** — 一键创建 VPS
|
|
40
|
+
- **服务端管理** — 一键创建 VPS 节点配置,自动生成密钥和客户端链接,支持 SOCKS5+FRP 内网穿透
|
|
41
41
|
|
|
42
42
|
## 📦 安装
|
|
43
43
|
|
|
@@ -255,6 +255,10 @@ v2box server create vless-reality -n "日本节点" -p 8443 --sni www.apple.com
|
|
|
255
255
|
# 创建 VLESS+WS 节点(配合 nginx 反代)
|
|
256
256
|
v2box server create vless-ws -n "WS节点" --path /my-secret
|
|
257
257
|
|
|
258
|
+
# 创建 SOCKS5 节点(配合 FRP 内网穿透)
|
|
259
|
+
v2box server create socks -n "内网节点"
|
|
260
|
+
v2box server create socks -n "内网节点" -p 10809 --user myuser --password mypass
|
|
261
|
+
|
|
258
262
|
# 查看已创建的配置
|
|
259
263
|
v2box server ls
|
|
260
264
|
|
|
@@ -268,6 +272,9 @@ v2box server link "WS节点" --ip 1.2.3.4 -d example.com
|
|
|
268
272
|
# 生成链接并直接导入本地
|
|
269
273
|
v2box server link "我的VPS" --ip 1.2.3.4 --import
|
|
270
274
|
|
|
275
|
+
# 生成 SOCKS 链接(需指定 FRP 穿透后的远端端口)
|
|
276
|
+
v2box server link "内网节点" --ip frp.example.com -p 16808
|
|
277
|
+
|
|
271
278
|
# 删除配置
|
|
272
279
|
v2box server rm "我的VPS"
|
|
273
280
|
v2box server rm 1
|
|
@@ -276,6 +283,7 @@ v2box server rm 1
|
|
|
276
283
|
支持的方案:
|
|
277
284
|
- **VLESS+Reality** — 免域名免证书,自动生成 UUID、Reality 密钥对、short_id
|
|
278
285
|
- **VLESS+WS** — 监听本地端口,由 nginx 反代 TLS,自动输出 nginx 配置片段
|
|
286
|
+
- **SOCKS5** — 适合无公网 IP 的服务器,配合 FRP 内网穿透,自动输出 FRP 配置片段
|
|
279
287
|
|
|
280
288
|
### `v2box info` — 环境信息
|
|
281
289
|
|
|
@@ -401,6 +409,22 @@ v2box server link "我的VPS" --ip 1.2.3.4 --import
|
|
|
401
409
|
v2box apply && v2box restart
|
|
402
410
|
```
|
|
403
411
|
|
|
412
|
+
### FRP 内网穿透(无公网 IP 服务器)
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
# 1. 创建 SOCKS5 配置(自动生成用户名密码 + FRP 配置片段)
|
|
416
|
+
v2box server create socks -n "内网节点"
|
|
417
|
+
|
|
418
|
+
# 2. 导出配置到容器服务器
|
|
419
|
+
v2box server export "内网节点" -o config.json
|
|
420
|
+
# 复制到容器并启动 sing-box
|
|
421
|
+
|
|
422
|
+
# 3. 在容器中配置 FRP 客户端(照着输出的 frpc.toml 片段配置)
|
|
423
|
+
# 4. 生成客户端链接并导入
|
|
424
|
+
v2box server link "内网节点" --ip frp.example.com -p 16808 --import
|
|
425
|
+
v2box apply && v2box restart
|
|
426
|
+
```
|
|
427
|
+
|
|
404
428
|
---
|
|
405
429
|
|
|
406
430
|
## ❓ 常见问题
|
|
@@ -442,6 +466,13 @@ v2box apply && v2box restart
|
|
|
442
466
|
> 服务端不需要(sing-box 不处理 TLS),但你需要一个域名配合 nginx 反代 HTTPS。
|
|
443
467
|
> 生成客户端链接时需要指定域名:`v2box server link "名称" --ip <IP> -d <域名>`
|
|
444
468
|
|
|
469
|
+
**Q: SOCKS5 方案安全吗?**
|
|
470
|
+
> SOCKS5 协议本身不加密,但通过 FRP 隧道传输时可以启用 FRP 的 TLS 加密(在 frpc.toml 中配置 `transport.tls`)。
|
|
471
|
+
> 另外建议始终开启用户名密码认证(默认已开启)。
|
|
472
|
+
|
|
473
|
+
**Q: 如何导入 socks:// 链接?**
|
|
474
|
+
> 直接用 `v2box add "socks://..."` 导入,支持 `socks://` 和 `socks5://` 两种前缀。
|
|
475
|
+
|
|
445
476
|
---
|
|
446
477
|
|
|
447
478
|
## 📄 License
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
## ✨ 功能特性
|
|
10
10
|
|
|
11
|
-
- **多协议支持** — VLESS、VMess、Shadowsocks、Trojan、Hysteria2
|
|
11
|
+
- **多协议支持** — VLESS、VMess、Shadowsocks、Trojan、Hysteria2、SOCKS5
|
|
12
12
|
- **一键导入** — 支持单条链接、文件批量导入
|
|
13
13
|
- **订阅管理** — 添加/更新/删除订阅,一键拉取节点,支持 Base64 自动解码
|
|
14
14
|
- **智能去重** — 基于配置内容去重,同名不同配置的节点自动区分
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
- **服务管理** — 启动、停止、重启 sing-box,一条命令搞定
|
|
19
19
|
- **简洁 CLI** — 命令短小好记,带中文帮助和示例
|
|
20
20
|
- **TUN 模式** — 默认开启全局透明代理(可关闭)
|
|
21
|
-
- **服务端管理** — 一键创建 VPS
|
|
21
|
+
- **服务端管理** — 一键创建 VPS 节点配置,自动生成密钥和客户端链接,支持 SOCKS5+FRP 内网穿透
|
|
22
22
|
|
|
23
23
|
## 📦 安装
|
|
24
24
|
|
|
@@ -236,6 +236,10 @@ v2box server create vless-reality -n "日本节点" -p 8443 --sni www.apple.com
|
|
|
236
236
|
# 创建 VLESS+WS 节点(配合 nginx 反代)
|
|
237
237
|
v2box server create vless-ws -n "WS节点" --path /my-secret
|
|
238
238
|
|
|
239
|
+
# 创建 SOCKS5 节点(配合 FRP 内网穿透)
|
|
240
|
+
v2box server create socks -n "内网节点"
|
|
241
|
+
v2box server create socks -n "内网节点" -p 10809 --user myuser --password mypass
|
|
242
|
+
|
|
239
243
|
# 查看已创建的配置
|
|
240
244
|
v2box server ls
|
|
241
245
|
|
|
@@ -249,6 +253,9 @@ v2box server link "WS节点" --ip 1.2.3.4 -d example.com
|
|
|
249
253
|
# 生成链接并直接导入本地
|
|
250
254
|
v2box server link "我的VPS" --ip 1.2.3.4 --import
|
|
251
255
|
|
|
256
|
+
# 生成 SOCKS 链接(需指定 FRP 穿透后的远端端口)
|
|
257
|
+
v2box server link "内网节点" --ip frp.example.com -p 16808
|
|
258
|
+
|
|
252
259
|
# 删除配置
|
|
253
260
|
v2box server rm "我的VPS"
|
|
254
261
|
v2box server rm 1
|
|
@@ -257,6 +264,7 @@ v2box server rm 1
|
|
|
257
264
|
支持的方案:
|
|
258
265
|
- **VLESS+Reality** — 免域名免证书,自动生成 UUID、Reality 密钥对、short_id
|
|
259
266
|
- **VLESS+WS** — 监听本地端口,由 nginx 反代 TLS,自动输出 nginx 配置片段
|
|
267
|
+
- **SOCKS5** — 适合无公网 IP 的服务器,配合 FRP 内网穿透,自动输出 FRP 配置片段
|
|
260
268
|
|
|
261
269
|
### `v2box info` — 环境信息
|
|
262
270
|
|
|
@@ -382,6 +390,22 @@ v2box server link "我的VPS" --ip 1.2.3.4 --import
|
|
|
382
390
|
v2box apply && v2box restart
|
|
383
391
|
```
|
|
384
392
|
|
|
393
|
+
### FRP 内网穿透(无公网 IP 服务器)
|
|
394
|
+
|
|
395
|
+
```bash
|
|
396
|
+
# 1. 创建 SOCKS5 配置(自动生成用户名密码 + FRP 配置片段)
|
|
397
|
+
v2box server create socks -n "内网节点"
|
|
398
|
+
|
|
399
|
+
# 2. 导出配置到容器服务器
|
|
400
|
+
v2box server export "内网节点" -o config.json
|
|
401
|
+
# 复制到容器并启动 sing-box
|
|
402
|
+
|
|
403
|
+
# 3. 在容器中配置 FRP 客户端(照着输出的 frpc.toml 片段配置)
|
|
404
|
+
# 4. 生成客户端链接并导入
|
|
405
|
+
v2box server link "内网节点" --ip frp.example.com -p 16808 --import
|
|
406
|
+
v2box apply && v2box restart
|
|
407
|
+
```
|
|
408
|
+
|
|
385
409
|
---
|
|
386
410
|
|
|
387
411
|
## ❓ 常见问题
|
|
@@ -423,6 +447,13 @@ v2box apply && v2box restart
|
|
|
423
447
|
> 服务端不需要(sing-box 不处理 TLS),但你需要一个域名配合 nginx 反代 HTTPS。
|
|
424
448
|
> 生成客户端链接时需要指定域名:`v2box server link "名称" --ip <IP> -d <域名>`
|
|
425
449
|
|
|
450
|
+
**Q: SOCKS5 方案安全吗?**
|
|
451
|
+
> SOCKS5 协议本身不加密,但通过 FRP 隧道传输时可以启用 FRP 的 TLS 加密(在 frpc.toml 中配置 `transport.tls`)。
|
|
452
|
+
> 另外建议始终开启用户名密码认证(默认已开启)。
|
|
453
|
+
|
|
454
|
+
**Q: 如何导入 socks:// 链接?**
|
|
455
|
+
> 直接用 `v2box add "socks://..."` 导入,支持 `socks://` 和 `socks5://` 两种前缀。
|
|
456
|
+
|
|
426
457
|
---
|
|
427
458
|
|
|
428
459
|
## 📄 License
|
|
@@ -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
|
|
|
@@ -828,11 +831,13 @@ def cmd_server():
|
|
|
828
831
|
支持方案:
|
|
829
832
|
vless-reality VLESS+Reality(免域名免证书,推荐)
|
|
830
833
|
vless-ws VLESS+WebSocket(配合 nginx 反代使用)
|
|
834
|
+
socks SOCKS5(适合 FRP 内网穿透场景)
|
|
831
835
|
|
|
832
836
|
\b
|
|
833
837
|
示例:
|
|
834
838
|
v2box server create vless-reality -n "我的VPS"
|
|
835
839
|
v2box server create vless-ws -n "WS节点" --path /secret
|
|
840
|
+
v2box server create socks -n "内网节点"
|
|
836
841
|
v2box server ls
|
|
837
842
|
v2box server export "我的VPS" -o config.json
|
|
838
843
|
v2box server link "我的VPS" --ip 1.2.3.4
|
|
@@ -842,36 +847,45 @@ def cmd_server():
|
|
|
842
847
|
|
|
843
848
|
|
|
844
849
|
@cmd_server.command("create")
|
|
845
|
-
@click.argument("scheme", type=click.Choice(["vless-reality", "vless-ws"]))
|
|
850
|
+
@click.argument("scheme", type=click.Choice(["vless-reality", "vless-ws", "socks"]))
|
|
846
851
|
@click.option("-n", "--name", required=True, help="节点名称(用于标识)")
|
|
847
|
-
@click.option("-p", "--port", type=int, default=None, help="监听端口(reality 默认 443,ws 默认 10001)")
|
|
852
|
+
@click.option("-p", "--port", type=int, default=None, help="监听端口(reality 默认 443,ws 默认 10001,socks 默认 10808)")
|
|
848
853
|
@click.option("--sni", default="www.microsoft.com", help="Reality SNI 伪装域名(默认 www.microsoft.com)")
|
|
849
854
|
@click.option("--path", default="/vless-ws", help="WebSocket 路径(默认 /vless-ws)")
|
|
850
|
-
|
|
855
|
+
@click.option("--user", default=None, help="SOCKS5 用户名(默认 v2box)")
|
|
856
|
+
@click.option("--password", "pwd", default=None, help="SOCKS5 密码(默认随机生成)")
|
|
857
|
+
def cmd_server_create(scheme, name, port, sni, path, user, pwd):
|
|
851
858
|
"""创建服务端节点配置。
|
|
852
859
|
|
|
853
860
|
\b
|
|
854
861
|
SCHEME 方案类型:
|
|
855
862
|
vless-reality VLESS+Reality,免域名免证书,直接监听端口
|
|
856
863
|
vless-ws VLESS+WebSocket,监听本地端口,由 nginx 反代
|
|
864
|
+
socks SOCKS5,适合 FRP 内网穿透场景
|
|
857
865
|
|
|
858
866
|
\b
|
|
859
867
|
示例:
|
|
860
868
|
v2box server create vless-reality -n "我的VPS"
|
|
861
869
|
v2box server create vless-reality -n "日本节点" -p 8443 --sni www.apple.com
|
|
862
870
|
v2box server create vless-ws -n "WS节点" -p 10002 --path /my-ws
|
|
871
|
+
v2box server create socks -n "内网节点"
|
|
872
|
+
v2box server create socks -n "内网节点" -p 10809 --user myuser --password mypass
|
|
863
873
|
"""
|
|
864
|
-
from v2box.core.server_config import create_vless_reality, create_vless_ws
|
|
874
|
+
from v2box.core.server_config import create_vless_reality, create_vless_ws, create_socks
|
|
865
875
|
from v2box.core.store import add_server
|
|
866
876
|
|
|
867
877
|
if scheme == "vless-reality":
|
|
868
878
|
p = port or 443
|
|
869
879
|
console.print(f"[dim]正在生成 VLESS+Reality 配置...[/dim]")
|
|
870
880
|
data = create_vless_reality(name=name, port=p, sni=sni)
|
|
871
|
-
|
|
881
|
+
elif scheme == "vless-ws":
|
|
872
882
|
p = port or 10001
|
|
873
883
|
console.print(f"[dim]正在生成 VLESS+WS 配置...[/dim]")
|
|
874
884
|
data = create_vless_ws(name=name, listen_port=p, ws_path=path)
|
|
885
|
+
else:
|
|
886
|
+
p = port or 10808
|
|
887
|
+
console.print(f"[dim]正在生成 SOCKS5 配置...[/dim]")
|
|
888
|
+
data = create_socks(name=name, listen_port=p, username=user, password=pwd)
|
|
875
889
|
|
|
876
890
|
if not add_server(data):
|
|
877
891
|
console.print(f"[red]✗[/red] 名称 [bold]{name}[/bold] 已存在")
|
|
@@ -885,10 +899,14 @@ def cmd_server_create(scheme, name, port, sni, path):
|
|
|
885
899
|
console.print(f" [bold]端口:[/bold] {meta['port']}")
|
|
886
900
|
console.print(f" [bold]SNI:[/bold] {meta['sni']}")
|
|
887
901
|
console.print(f" [bold]UUID:[/bold] {meta['uuid']}")
|
|
888
|
-
|
|
902
|
+
elif scheme == "vless-ws":
|
|
889
903
|
console.print(f" [bold]监听:[/bold] 127.0.0.1:{meta['listen_port']}")
|
|
890
904
|
console.print(f" [bold]路径:[/bold] {meta['ws_path']}")
|
|
891
905
|
console.print(f" [bold]UUID:[/bold] {meta['uuid']}")
|
|
906
|
+
elif scheme == "socks":
|
|
907
|
+
console.print(f" [bold]监听:[/bold] 127.0.0.1:{meta['listen_port']}")
|
|
908
|
+
console.print(f" [bold]用户:[/bold] {meta['username']}")
|
|
909
|
+
console.print(f" [bold]密码:[/bold] {meta['password']}")
|
|
892
910
|
|
|
893
911
|
console.print(f"\n[dim]下一步:[/dim]")
|
|
894
912
|
console.print(f" [dim]导出配置: v2box server export \"{name}\" -o config.json[/dim]")
|
|
@@ -898,6 +916,10 @@ def cmd_server_create(scheme, name, port, sni, path):
|
|
|
898
916
|
console.print(f"\n[bold yellow]nginx 配置片段:[/bold yellow]")
|
|
899
917
|
console.print(Panel(data["nginx_snippet"], title="nginx.conf", border_style="dim"))
|
|
900
918
|
|
|
919
|
+
if scheme == "socks" and "frp_snippet" in data:
|
|
920
|
+
console.print(f"\n[bold yellow]FRP 客户端配置片段:[/bold yellow]")
|
|
921
|
+
console.print(Panel(data["frp_snippet"], title="frpc.toml", border_style="dim"))
|
|
922
|
+
|
|
901
923
|
|
|
902
924
|
@cmd_server.command("ls")
|
|
903
925
|
def cmd_server_ls():
|
|
@@ -919,12 +941,13 @@ def cmd_server_ls():
|
|
|
919
941
|
table.add_column("名称", style="bold")
|
|
920
942
|
table.add_column("方案", style="cyan")
|
|
921
943
|
table.add_column("端口", justify="right")
|
|
922
|
-
table.add_column("
|
|
944
|
+
table.add_column("标识", style="dim", max_width=24, overflow="ellipsis")
|
|
923
945
|
|
|
924
946
|
for i, s in enumerate(servers, 1):
|
|
925
947
|
meta = s["meta"]
|
|
926
948
|
p = str(meta.get("port", meta.get("listen_port", "")))
|
|
927
|
-
|
|
949
|
+
identity = meta.get("uuid", meta.get("username", ""))
|
|
950
|
+
table.add_row(str(i), meta["name"], meta["type"], p, identity)
|
|
928
951
|
|
|
929
952
|
console.print(table)
|
|
930
953
|
|
|
@@ -973,10 +996,11 @@ def cmd_server_export(name, output):
|
|
|
973
996
|
|
|
974
997
|
@cmd_server.command("link")
|
|
975
998
|
@click.argument("name")
|
|
976
|
-
@click.option("--ip", "server_ip", required=True, help="服务器公网 IP
|
|
999
|
+
@click.option("--ip", "server_ip", required=True, help="服务器公网 IP 地址(或 FRP 服务器地址)")
|
|
1000
|
+
@click.option("-p", "--port", "remote_port", type=int, default=None, help="远端端口(SOCKS+FRP 穿透后的端口)")
|
|
977
1001
|
@click.option("-d", "--domain", default=None, help="域名(VLESS+WS 方案需要)")
|
|
978
1002
|
@click.option("--import", "do_import", is_flag=True, help="同时导入到本地节点列表")
|
|
979
|
-
def cmd_server_link(name, server_ip, domain, do_import):
|
|
1003
|
+
def cmd_server_link(name, server_ip, remote_port, domain, do_import):
|
|
980
1004
|
"""生成客户端连接链接。
|
|
981
1005
|
|
|
982
1006
|
\b
|
|
@@ -986,10 +1010,11 @@ def cmd_server_link(name, server_ip, domain, do_import):
|
|
|
986
1010
|
示例:
|
|
987
1011
|
v2box server link "我的VPS" --ip 1.2.3.4
|
|
988
1012
|
v2box server link "WS节点" --ip 1.2.3.4 -d example.com
|
|
1013
|
+
v2box server link "内网节点" --ip frp.example.com -p 16808
|
|
989
1014
|
v2box server link "我的VPS" --ip 1.2.3.4 --import
|
|
990
1015
|
"""
|
|
991
1016
|
from v2box.core.store import load_servers, get_server
|
|
992
|
-
from v2box.core.link_builder import build_vless_link
|
|
1017
|
+
from v2box.core.link_builder import build_vless_link, build_socks_link
|
|
993
1018
|
import copy
|
|
994
1019
|
|
|
995
1020
|
# 支持按序号
|
|
@@ -1019,8 +1044,20 @@ def cmd_server_link(name, server_ip, domain, do_import):
|
|
|
1019
1044
|
outbound["server"] = domain
|
|
1020
1045
|
outbound["server_port"] = 443
|
|
1021
1046
|
outbound["tls"]["server_name"] = domain
|
|
1047
|
+
elif meta["type"] == "socks":
|
|
1048
|
+
outbound["server"] = server_ip
|
|
1049
|
+
if remote_port:
|
|
1050
|
+
outbound["server_port"] = remote_port
|
|
1051
|
+
else:
|
|
1052
|
+
console.print("[red]✗[/red] SOCKS 方案需要指定远端端口(FRP 穿透端口): --port / -p")
|
|
1053
|
+
return
|
|
1054
|
+
|
|
1055
|
+
# 根据类型选择链接生成器
|
|
1056
|
+
if meta["type"] == "socks":
|
|
1057
|
+
link = build_socks_link(outbound)
|
|
1058
|
+
else:
|
|
1059
|
+
link = build_vless_link(outbound)
|
|
1022
1060
|
|
|
1023
|
-
link = build_vless_link(outbound)
|
|
1024
1061
|
console.print(f"\n[bold green]客户端连接链接:[/bold green]")
|
|
1025
1062
|
console.print(f" {link}")
|
|
1026
1063
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""客户端连接链接生成器 — 从 outbound 字典生成分享链接。"""
|
|
2
2
|
|
|
3
|
+
import base64
|
|
3
4
|
from urllib.parse import quote, urlencode
|
|
4
5
|
|
|
5
6
|
|
|
@@ -63,3 +64,25 @@ def build_vless_link(outbound: dict) -> str:
|
|
|
63
64
|
query = urlencode(params, safe="/:@")
|
|
64
65
|
|
|
65
66
|
return f"vless://{uuid}@{server}:{port}?{query}#{fragment}"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def build_socks_link(outbound: dict) -> str:
|
|
70
|
+
"""从 SOCKS outbound 字典生成 socks:// 链接。
|
|
71
|
+
|
|
72
|
+
格式: socks://base64(user:pass)@host:port#tag
|
|
73
|
+
"""
|
|
74
|
+
server = outbound["server"]
|
|
75
|
+
port = outbound["server_port"]
|
|
76
|
+
tag = outbound.get("tag", "socks")
|
|
77
|
+
|
|
78
|
+
username = outbound.get("username", "")
|
|
79
|
+
password = outbound.get("password", "")
|
|
80
|
+
|
|
81
|
+
fragment = quote(str(tag), safe="")
|
|
82
|
+
|
|
83
|
+
if username:
|
|
84
|
+
cred = f"{username}:{password}"
|
|
85
|
+
encoded = base64.urlsafe_b64encode(cred.encode("utf-8")).decode("ascii").rstrip("=")
|
|
86
|
+
return f"socks://{encoded}@{server}:{port}#{fragment}"
|
|
87
|
+
else:
|
|
88
|
+
return f"socks://{server}:{port}#{fragment}"
|
|
@@ -218,6 +218,87 @@ location {ws_path} {{
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
|
|
221
|
+
def _generate_password(length: int = 16) -> str:
|
|
222
|
+
"""生成随机密码。"""
|
|
223
|
+
import string
|
|
224
|
+
alphabet = string.ascii_letters + string.digits
|
|
225
|
+
return "".join(secrets.choice(alphabet) for _ in range(length))
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def create_socks(
|
|
229
|
+
name: str,
|
|
230
|
+
listen_port: int = 10808,
|
|
231
|
+
username: str | None = None,
|
|
232
|
+
password: str | None = None,
|
|
233
|
+
) -> dict:
|
|
234
|
+
"""创建 SOCKS5 服务端配置(适合 FRP 内网穿透场景)。
|
|
235
|
+
|
|
236
|
+
Returns:
|
|
237
|
+
包含 server_config, client_outbound, meta, frp_snippet 的字典
|
|
238
|
+
"""
|
|
239
|
+
if not username:
|
|
240
|
+
username = "v2box"
|
|
241
|
+
if not password:
|
|
242
|
+
password = _generate_password()
|
|
243
|
+
|
|
244
|
+
server_config = {
|
|
245
|
+
"log": {"level": "info"},
|
|
246
|
+
"inbounds": [
|
|
247
|
+
{
|
|
248
|
+
"type": "socks",
|
|
249
|
+
"tag": "socks-in",
|
|
250
|
+
"listen": "127.0.0.1",
|
|
251
|
+
"listen_port": listen_port,
|
|
252
|
+
"users": [
|
|
253
|
+
{
|
|
254
|
+
"username": username,
|
|
255
|
+
"password": password,
|
|
256
|
+
}
|
|
257
|
+
],
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
"outbounds": [{"type": "direct", "tag": "direct"}],
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
# 客户端 outbound 模板
|
|
264
|
+
client_outbound = {
|
|
265
|
+
"type": "socks",
|
|
266
|
+
"tag": name,
|
|
267
|
+
"server": "{server_ip}",
|
|
268
|
+
"server_port": "{frp_remote_port}",
|
|
269
|
+
"version": "5",
|
|
270
|
+
"username": username,
|
|
271
|
+
"password": password,
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
# FRP 配置片段(TOML 格式,frpc.toml)
|
|
275
|
+
frp_snippet = f"""\
|
|
276
|
+
# FRP 客户端配置片段(添加到 frpc.toml)
|
|
277
|
+
# 将容器内的 SOCKS5 端口穿透到 FRP 服务器
|
|
278
|
+
|
|
279
|
+
[[proxies]]
|
|
280
|
+
name = "{name}"
|
|
281
|
+
type = "tcp"
|
|
282
|
+
localIP = "127.0.0.1"
|
|
283
|
+
localPort = {listen_port}
|
|
284
|
+
remotePort = 0 # 设为 0 由服务端自动分配,或指定固定端口如 16808"""
|
|
285
|
+
|
|
286
|
+
meta = {
|
|
287
|
+
"name": name,
|
|
288
|
+
"type": "socks",
|
|
289
|
+
"listen_port": listen_port,
|
|
290
|
+
"username": username,
|
|
291
|
+
"password": password,
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return {
|
|
295
|
+
"server_config": server_config,
|
|
296
|
+
"client_outbound": client_outbound,
|
|
297
|
+
"meta": meta,
|
|
298
|
+
"frp_snippet": frp_snippet,
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
|
|
221
302
|
def server_config_to_json(config: dict) -> str:
|
|
222
303
|
"""将服务端配置转为格式化 JSON。"""
|
|
223
304
|
return json.dumps(config, indent=2, ensure_ascii=False)
|
|
@@ -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"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
"""协议链接解析模块,支持 vless / vmess / ss / trojan / hysteria2"""
|
|
1
|
+
"""协议链接解析模块,支持 vless / vmess / ss / trojan / hysteria2 / socks"""
|
|
2
2
|
|
|
3
3
|
from v2box.parsers.vless import parse_vless
|
|
4
4
|
from v2box.parsers.vmess import parse_vmess
|
|
5
5
|
from v2box.parsers.shadowsocks import parse_ss
|
|
6
6
|
from v2box.parsers.trojan import parse_trojan
|
|
7
7
|
from v2box.parsers.hysteria2 import parse_hysteria2
|
|
8
|
+
from v2box.parsers.socks import parse_socks
|
|
8
9
|
|
|
9
10
|
# 协议前缀 -> 解析函数 的映射
|
|
10
11
|
PARSERS = {
|
|
@@ -14,6 +15,8 @@ PARSERS = {
|
|
|
14
15
|
"trojan://": parse_trojan,
|
|
15
16
|
"hysteria2://": parse_hysteria2,
|
|
16
17
|
"hy2://": parse_hysteria2,
|
|
18
|
+
"socks://": parse_socks,
|
|
19
|
+
"socks5://": parse_socks,
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
|
|
@@ -31,4 +34,4 @@ def parse_link(link: str) -> dict | None:
|
|
|
31
34
|
|
|
32
35
|
def supported_protocols() -> list[str]:
|
|
33
36
|
"""返回支持的协议列表。"""
|
|
34
|
-
return ["vless", "vmess", "ss (Shadowsocks)", "trojan", "hysteria2 / hy2"]
|
|
37
|
+
return ["vless", "vmess", "ss (Shadowsocks)", "trojan", "hysteria2 / hy2", "socks / socks5"]
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""SOCKS5 链接解析器
|
|
2
|
+
|
|
3
|
+
链接格式:
|
|
4
|
+
socks://base64(user:pass)@host:port#tag (有认证)
|
|
5
|
+
socks://host:port#tag (无认证)
|
|
6
|
+
socks5://... (同上,别名)
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import base64
|
|
10
|
+
from urllib.parse import unquote
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def parse_socks(link: str) -> dict | None:
|
|
14
|
+
"""解析 socks:// 或 socks5:// 链接,返回 sing-box outbound 字典。"""
|
|
15
|
+
link = link.strip()
|
|
16
|
+
lower = link.lower()
|
|
17
|
+
if lower.startswith("socks5://"):
|
|
18
|
+
rest = link[len("socks5://"):]
|
|
19
|
+
elif lower.startswith("socks://"):
|
|
20
|
+
rest = link[len("socks://"):]
|
|
21
|
+
else:
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
# 提取 fragment(节点名)
|
|
25
|
+
tag = ""
|
|
26
|
+
if "#" in rest:
|
|
27
|
+
rest, tag = rest.rsplit("#", 1)
|
|
28
|
+
tag = unquote(tag)
|
|
29
|
+
|
|
30
|
+
username = ""
|
|
31
|
+
password = ""
|
|
32
|
+
|
|
33
|
+
if "@" in rest:
|
|
34
|
+
user_part, host_part = rest.rsplit("@", 1)
|
|
35
|
+
# 尝试 Base64 解码 user:pass
|
|
36
|
+
try:
|
|
37
|
+
decoded = base64.urlsafe_b64decode(user_part + "==").decode("utf-8")
|
|
38
|
+
if ":" in decoded:
|
|
39
|
+
username, password = decoded.split(":", 1)
|
|
40
|
+
else:
|
|
41
|
+
username = decoded
|
|
42
|
+
except Exception:
|
|
43
|
+
# 非 Base64,直接作为 user:pass
|
|
44
|
+
if ":" in user_part:
|
|
45
|
+
username, password = user_part.split(":", 1)
|
|
46
|
+
username = unquote(username)
|
|
47
|
+
password = unquote(password)
|
|
48
|
+
else:
|
|
49
|
+
username = unquote(user_part)
|
|
50
|
+
else:
|
|
51
|
+
host_part = rest
|
|
52
|
+
|
|
53
|
+
server, _, port_str = host_part.rpartition(":")
|
|
54
|
+
if not server or not port_str:
|
|
55
|
+
return None
|
|
56
|
+
# 处理 IPv6 [::1] 格式
|
|
57
|
+
server = server.strip("[]")
|
|
58
|
+
port = int(port_str)
|
|
59
|
+
|
|
60
|
+
outbound = {
|
|
61
|
+
"type": "socks",
|
|
62
|
+
"tag": tag or f"socks-{server}:{port}",
|
|
63
|
+
"server": server,
|
|
64
|
+
"server_port": port,
|
|
65
|
+
"version": "5",
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if username:
|
|
69
|
+
outbound["username"] = username
|
|
70
|
+
if password:
|
|
71
|
+
outbound["password"] = password
|
|
72
|
+
|
|
73
|
+
return outbound
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: v2box
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: 一键将代理节点链接导入 sing-box,轻松管理、测速、切换节点
|
|
5
5
|
Author: v2box contributors
|
|
6
6
|
License-Expression: MIT
|
|
@@ -27,7 +27,7 @@ Requires-Dist: rich>=13.0
|
|
|
27
27
|
|
|
28
28
|
## ✨ 功能特性
|
|
29
29
|
|
|
30
|
-
- **多协议支持** — VLESS、VMess、Shadowsocks、Trojan、Hysteria2
|
|
30
|
+
- **多协议支持** — VLESS、VMess、Shadowsocks、Trojan、Hysteria2、SOCKS5
|
|
31
31
|
- **一键导入** — 支持单条链接、文件批量导入
|
|
32
32
|
- **订阅管理** — 添加/更新/删除订阅,一键拉取节点,支持 Base64 自动解码
|
|
33
33
|
- **智能去重** — 基于配置内容去重,同名不同配置的节点自动区分
|
|
@@ -37,7 +37,7 @@ Requires-Dist: rich>=13.0
|
|
|
37
37
|
- **服务管理** — 启动、停止、重启 sing-box,一条命令搞定
|
|
38
38
|
- **简洁 CLI** — 命令短小好记,带中文帮助和示例
|
|
39
39
|
- **TUN 模式** — 默认开启全局透明代理(可关闭)
|
|
40
|
-
- **服务端管理** — 一键创建 VPS
|
|
40
|
+
- **服务端管理** — 一键创建 VPS 节点配置,自动生成密钥和客户端链接,支持 SOCKS5+FRP 内网穿透
|
|
41
41
|
|
|
42
42
|
## 📦 安装
|
|
43
43
|
|
|
@@ -255,6 +255,10 @@ v2box server create vless-reality -n "日本节点" -p 8443 --sni www.apple.com
|
|
|
255
255
|
# 创建 VLESS+WS 节点(配合 nginx 反代)
|
|
256
256
|
v2box server create vless-ws -n "WS节点" --path /my-secret
|
|
257
257
|
|
|
258
|
+
# 创建 SOCKS5 节点(配合 FRP 内网穿透)
|
|
259
|
+
v2box server create socks -n "内网节点"
|
|
260
|
+
v2box server create socks -n "内网节点" -p 10809 --user myuser --password mypass
|
|
261
|
+
|
|
258
262
|
# 查看已创建的配置
|
|
259
263
|
v2box server ls
|
|
260
264
|
|
|
@@ -268,6 +272,9 @@ v2box server link "WS节点" --ip 1.2.3.4 -d example.com
|
|
|
268
272
|
# 生成链接并直接导入本地
|
|
269
273
|
v2box server link "我的VPS" --ip 1.2.3.4 --import
|
|
270
274
|
|
|
275
|
+
# 生成 SOCKS 链接(需指定 FRP 穿透后的远端端口)
|
|
276
|
+
v2box server link "内网节点" --ip frp.example.com -p 16808
|
|
277
|
+
|
|
271
278
|
# 删除配置
|
|
272
279
|
v2box server rm "我的VPS"
|
|
273
280
|
v2box server rm 1
|
|
@@ -276,6 +283,7 @@ v2box server rm 1
|
|
|
276
283
|
支持的方案:
|
|
277
284
|
- **VLESS+Reality** — 免域名免证书,自动生成 UUID、Reality 密钥对、short_id
|
|
278
285
|
- **VLESS+WS** — 监听本地端口,由 nginx 反代 TLS,自动输出 nginx 配置片段
|
|
286
|
+
- **SOCKS5** — 适合无公网 IP 的服务器,配合 FRP 内网穿透,自动输出 FRP 配置片段
|
|
279
287
|
|
|
280
288
|
### `v2box info` — 环境信息
|
|
281
289
|
|
|
@@ -401,6 +409,22 @@ v2box server link "我的VPS" --ip 1.2.3.4 --import
|
|
|
401
409
|
v2box apply && v2box restart
|
|
402
410
|
```
|
|
403
411
|
|
|
412
|
+
### FRP 内网穿透(无公网 IP 服务器)
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
# 1. 创建 SOCKS5 配置(自动生成用户名密码 + FRP 配置片段)
|
|
416
|
+
v2box server create socks -n "内网节点"
|
|
417
|
+
|
|
418
|
+
# 2. 导出配置到容器服务器
|
|
419
|
+
v2box server export "内网节点" -o config.json
|
|
420
|
+
# 复制到容器并启动 sing-box
|
|
421
|
+
|
|
422
|
+
# 3. 在容器中配置 FRP 客户端(照着输出的 frpc.toml 片段配置)
|
|
423
|
+
# 4. 生成客户端链接并导入
|
|
424
|
+
v2box server link "内网节点" --ip frp.example.com -p 16808 --import
|
|
425
|
+
v2box apply && v2box restart
|
|
426
|
+
```
|
|
427
|
+
|
|
404
428
|
---
|
|
405
429
|
|
|
406
430
|
## ❓ 常见问题
|
|
@@ -442,6 +466,13 @@ v2box apply && v2box restart
|
|
|
442
466
|
> 服务端不需要(sing-box 不处理 TLS),但你需要一个域名配合 nginx 反代 HTTPS。
|
|
443
467
|
> 生成客户端链接时需要指定域名:`v2box server link "名称" --ip <IP> -d <域名>`
|
|
444
468
|
|
|
469
|
+
**Q: SOCKS5 方案安全吗?**
|
|
470
|
+
> SOCKS5 协议本身不加密,但通过 FRP 隧道传输时可以启用 FRP 的 TLS 加密(在 frpc.toml 中配置 `transport.tls`)。
|
|
471
|
+
> 另外建议始终开启用户名密码认证(默认已开启)。
|
|
472
|
+
|
|
473
|
+
**Q: 如何导入 socks:// 链接?**
|
|
474
|
+
> 直接用 `v2box add "socks://..."` 导入,支持 `socks://` 和 `socks5://` 两种前缀。
|
|
475
|
+
|
|
445
476
|
---
|
|
446
477
|
|
|
447
478
|
## 📄 License
|
|
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
|