[![PyPI - Version](https://img.shields.io/pypi/v/v2raysub)](https://pypi.org/project/v2raysub/) [![Build Status](https://github.com/12CrazyPaul21/v2raysub/actions/workflows/build-and-test-v2sub.yml/badge.svg)](https://github.com/12CrazyPaul21/v2raysub/actions) [![MIT/Apache-2 licensed](https://img.shields.io/crates/l/lopxy.svg)](./LICENSE)
# v2raysub
v2sub 主要是为了给在纯命令的 Linux 环境使用 v2ray 提供一些辅助,比如订阅分组、切换节点配置、给 proxychains 创建别名等。虽然工具能在 Windows 和 Mac 环境使用,但是对于桌面环境,可以考虑其它选择,比如 [v2rayN](https://github.com/2dust/v2rayN)。
## 安装方法
```bash
pip install v2raysub
```
v2sub 依赖 v2ray,除了 [手动安装](https://www.v2ray.com/chapter_00/install.html) 外,也可以在安装了 v2sub 后通过以下命令尝试安装
```bash
v2sub install v2ray
# 如果网不通,可尝试指定可用的代理
v2sub install --proxy <server:port> v2ray
```
proxychains 工具不是必须的,需要的话也可以通过 v2sub 尝试安装
```bash
v2sub install proxychains
```
## 订阅分享支持的链接格式
- [x] shadowsocks(`ss://[method:]<password>@<server>:<port>[#remark]` | `ss://base64`)
- [x] trojan(`trojan://<password>@<server>:<port>[?options...}[#remark]` | `trojan://base64`)
- [x] vmess(`vmess://base64`)
- [x] http / https(订阅分组)
- [ ] 其它协议,可以用编写 plugins 的方式,自定义解析和生成 outbound 配置
## 注意事项
- 确保 v2ray 和 proxychains 所在的目录已经添加到了 `PATH ` 环境变量中,使 v2sub 能够找到它们(对于Windows,如果通过 `v2sub install` 安装的话,则不需要)
- 对于 Mac 环境,由于 SIP(System Integrity Protection)特性,一些在 `/usr/bin/` 等目录中的命令不能直接走代理,比如 `/usr/bin/curl`。这可以用命令对应的参数来指定代理,像 `curl` 可以使用 `--proxy` 来指定,也可以考虑进 `Recovery` 模式执行 `csrutil disable` 来将 SIP 禁掉。
## v2ray服务启动方式
v2sub 有两种启动 v2ray 服务的模式:
1. `v2sub node start `(临时服务):主要是给临时使用的,不过即使 `shell` 退出了,它也会在后台运行,可以通过 `v2sub node stop` 停止
2. `v2sub service start`(系统服务):以系统服务方式运行,运行前需要通过 `v2sub service install` 来安装服务,默认是自启动的,对于 Linux 环境,只支持 `systemd` 类型的服务管理器
## 使用方法
> 除了下面说明外,更多使用方法可直接看 `v2sub --help`
### 1. 初始化配置
```bash
v2sub init
```
这一步是必须的,这会在家目录的 `.v2sub` 文件夹内生成一个初始的 v2ray 配置文件 `base_config.json`,里面没有 `outbounds` 的设置,在实际启动 v2ray 的时候,会根据这个文件生成对应的配置文件。
初始化之后可根据需要执行 `v2sub config edit` 来对配置文件进行修改,配置条目的说明可以看:[v2ray 配置文件](https://www.v2ray.com/chapter_02/),修改完成之后,在 Linux 和 Mac 环境中会对 v2ray 服务自动重启,而 Windows 需要手动重启。
### 2. 订阅节点或者节点分组
```bash
# 添加
v2sub subscribe add <url>
# 更新分组
v2sub subscribe update
v2sub subscribe update --all
# 删除节点或分组
v2sub subscribe delete
v2sub subscribe delete --all
# 查看订阅列表
v2sub subscribe show
# 纯解析节点或分组,不会添加到列表中
v2sub subscribe parse <url>
```
url 可以是单个节点(比如: `ss://...`),也可以是分组订阅链接(比如:`https://xxx.com/subscribe?token=xxx`),订阅分组需要执行 http 请求,如果网不通可以指定可用的代理
```bash
v2sub subscribe --proxy <server:port> add <url>
```
### 3. 选择节点
在启动临时服务或者安装系统服务前都得先选择一个节点以生成对应的 v2ray 配置文件,这两种模式选择节点的方法分别是:
1. `v2sub node select`
2. `v2sub service select`
如果订阅列表中有独立节点和分组,会有类似下面的选择提示:
```bash
# anonymous内是独立节点列表,groups则是分组列表
choose subscribe type:
» base config
anonymous
groups
<Cancel>
# base config 指的是直接复用默认的base_config.json里面的设置,默认没有配置带proxy tag的outbound
# anonymous 指的是直接以类似 ss://...,这种方式添加的非分组的订阅链接
# groups 指的是订阅分组
```
**notes: **在服务启动之后也可以重新执行 `select` 来切换节点
### 4. 启动临时服务
```bash
# 启动
v2sub node start
# 停止
v2sub node stop
# 重启
v2sub node restart
# 查看运行状态
v2sub node status
# 切换节点
v2sub node select
```
默认端口号:
- sock5: 23338
- http: 23339
### 5. 安装和启动 v2sub 系统服务
```bash
# 安装服务(Windows环境这一步需要编译服务,可能需要些时间)
v2sub service install
# 启动服务
v2sub service start
# 停止服务
v2sub service stop
# 重启
v2sub service restart
# 查看服务运行状态
v2sub service status
# 切换节点
v2sub service select
# 卸载服务
v2sub service uninstall
```
默认端口号:
- sock5: 22338
- http: 22339
### 6. 应用代理
#### a. shell 内临时生效
```bash
# linux shell
export http_proxy='http://127.0.0.1:<端口号>'
export https_proxy='http://127.0.0.1:<端口号>'
# powershell
$env:http_proxy='http://127.0.0.1:<端口号>'
$env:https_proxy='http://127.0.0.1:<端口号>'
# cmd
set http_proxy=http://127.0.0.1:<端口号>
set https_proxy=http://127.0.0.1:<端口号>
```
#### b. proxychains 别名
```bash
# 执行后会提示你选择应用的是临时服务还是系统服务模式,并提供别名
v2sub proxychains alias
# 删除别名
v2sub proxychains alias --delete <别名>
# 显示所有别名
v2sub proxychains alias --list-all
```
创建别名之后,在 Windows 环境需要重启你的 powershell 或者 cmd,Linux 或 Mac 需要执行 `source <shell配置文件>` 来使别名生效。
这只是创建一个 proxychains 的配置文件和命令别名,不会对 v2ray 服务运行有影响,使用的时候要确保对应的服务运行中。
```bash
# 比如创建了一个别名为vproxy,在确保对应的服务运行后,可以这样使用
vproxy curl https://ipinfo.io/ip
```
#### c. 系统代理设置
对于 Windows 和 Mac 执行以下命令可以启用或禁用系统代理设置,Windows 是修改 IE 的 http 代理设置,Mac 则是修改网络接口的 http 和 socks 设置。对于 Linux,由于发行版众多,v2sub 的目标也不是桌面环境,所以不提供这个设置,有需要的话手动设置。
```bash
# 启用
v2sub config proxy enable
# 禁用
v2sub config proxy disable
```
#### d. 允许局域网连接
使用以下两个命令可以允许或禁止其它机器连接对应的代理服务,为了安全起见,修改之后请手动添加或删除防火墙规则。
```bash
# 允许
v2sub config lan allow
# 禁止
v2sub config lan disallow
```
### 7. 路由规则设置
```bash
# 可以用以下命令管理direct或block路由规则
# 添加direct规则
v2sub config direct add
# 删除direct规则
v2sub config direct remove
# 查看direct规则
v2sub config direct list
# 添加block规则
v2sub config block add
# 删除block规则
v2sub config block remove
# 查看block规则
v2sub config block list
```
## Plugin
可以在 `~/.v2sub/plugins` 目录中,添加自定义的 python 脚本,v2sub 在初始化时会自动加载里面的所有脚本。这主要是为了能自定义解析一些除了 v2sub 本来不支持的其它协议,对于 ss、trojan、vmess 这些 v2sub 本来支持的协议,如果在解析或者生成配置文件有问题,也可以在扩展中将原本的解析方法给替换掉。
```python
# 扩展例子 ~/.v2sub/plugins/hh.py
import re
from urllib.parse import urlparse, unquote, ParseResult
from v2raysub import cli as v2cli, protocol, util
# 给 v2sub 添加了两个新命令
# 可以用 v2sub foo 和 v2sub bar 来调用这两个命令
@v2cli.cli.command("foo")
def foo():
print('foo command')
@v2cli.cli.command("bar")
def bar():
print('bar command')
# 解析 hh://...
def parse_hh(url: ParseResult) -> object:
result = {'success': 0}
url = urlparse(f'hh://{protocol.regular_content(url)}')
pattern = r'^(?P<password>.+)@(?P<server>.+):(?P<port>\d+)$'
match = re.match(pattern, url.netloc)
if match is None:
result['reason'] = 'invalid hoohoo params'
return result
result['success'] = 1
result['protocol'] = 'hoohoo'
result['remark'] = unquote(url.fragment)
result['server'] = match['server']
result['port'] = match['port']
result['identify'] = match['password']
result['method'] = 'chacha20'
result['options'] = util.parse_query_string(url.query)
return result
# 为 hoohoo 这个假的协议生成 v2ray 配置文件
def generate_hoohoo_outbound(config, node, node_info, node_options) -> object:
config['settings']['servers'] = [{
'address': node_info['server'],
'method': node_info['method'],
'ota': False,
'password': node_info['identify'],
'port': int(node_info['port'])
}]
config['streamSettings'] = {
"network": "tcp"
}
if node_options.get('tls', '0') == '1':
config['streamSettings']['security'] = 'tls'
return config
# init_plugin 会被 v2sub 自动调用
def init_plugin(app):
# 注册 url 解析器
protocol.register_parser('hh', parse_hh)
# 注册配置文件生成器
protocol.register_generator('hoohoo', generate_hoohoo_outbound)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/12CrazyPaul21/v2raysub",
"name": "v2raysub",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "v2ray, config, subscribe, proxy, proxychains",
"author": "hzq",
"author_email": "604916833@qq.com",
"download_url": "https://files.pythonhosted.org/packages/5b/b8/0f423b79a523b0c4d5457b1c09e85c7050827c0dcc278c9330c233a8565d/v2raysub-0.3.1.tar.gz",
"platform": null,
"description": "[![PyPI - Version](https://img.shields.io/pypi/v/v2raysub)](https://pypi.org/project/v2raysub/) [![Build Status](https://github.com/12CrazyPaul21/v2raysub/actions/workflows/build-and-test-v2sub.yml/badge.svg)](https://github.com/12CrazyPaul21/v2raysub/actions) [![MIT/Apache-2 licensed](https://img.shields.io/crates/l/lopxy.svg)](./LICENSE)\n\n# v2raysub\n\nv2sub \u4e3b\u8981\u662f\u4e3a\u4e86\u7ed9\u5728\u7eaf\u547d\u4ee4\u7684 Linux \u73af\u5883\u4f7f\u7528 v2ray \u63d0\u4f9b\u4e00\u4e9b\u8f85\u52a9\uff0c\u6bd4\u5982\u8ba2\u9605\u5206\u7ec4\u3001\u5207\u6362\u8282\u70b9\u914d\u7f6e\u3001\u7ed9 proxychains \u521b\u5efa\u522b\u540d\u7b49\u3002\u867d\u7136\u5de5\u5177\u80fd\u5728 Windows \u548c Mac \u73af\u5883\u4f7f\u7528\uff0c\u4f46\u662f\u5bf9\u4e8e\u684c\u9762\u73af\u5883\uff0c\u53ef\u4ee5\u8003\u8651\u5176\u5b83\u9009\u62e9\uff0c\u6bd4\u5982 [v2rayN](https://github.com/2dust/v2rayN)\u3002\n\n## \u5b89\u88c5\u65b9\u6cd5\n\n```bash\npip install v2raysub\n```\n\nv2sub \u4f9d\u8d56 v2ray\uff0c\u9664\u4e86 [\u624b\u52a8\u5b89\u88c5](https://www.v2ray.com/chapter_00/install.html) \u5916\uff0c\u4e5f\u53ef\u4ee5\u5728\u5b89\u88c5\u4e86 v2sub \u540e\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5c1d\u8bd5\u5b89\u88c5\n\n```bash\nv2sub install v2ray\n# \u5982\u679c\u7f51\u4e0d\u901a\uff0c\u53ef\u5c1d\u8bd5\u6307\u5b9a\u53ef\u7528\u7684\u4ee3\u7406\nv2sub install --proxy <server:port> v2ray\n```\n\nproxychains \u5de5\u5177\u4e0d\u662f\u5fc5\u987b\u7684\uff0c\u9700\u8981\u7684\u8bdd\u4e5f\u53ef\u4ee5\u901a\u8fc7 v2sub \u5c1d\u8bd5\u5b89\u88c5\n\n```bash\nv2sub install proxychains\n```\n\n## \u8ba2\u9605\u5206\u4eab\u652f\u6301\u7684\u94fe\u63a5\u683c\u5f0f\n\n- [x] shadowsocks\uff08`ss://[method:]<password>@<server>:<port>[#remark]` | `ss://base64`\uff09\n- [x] trojan\uff08`trojan://<password>@<server>:<port>[?options...}[#remark]` | `trojan://base64`\uff09\n- [x] vmess\uff08`vmess://base64`\uff09\n- [x] http / https\uff08\u8ba2\u9605\u5206\u7ec4\uff09\n- [ ] \u5176\u5b83\u534f\u8bae\uff0c\u53ef\u4ee5\u7528\u7f16\u5199 plugins \u7684\u65b9\u5f0f\uff0c\u81ea\u5b9a\u4e49\u89e3\u6790\u548c\u751f\u6210 outbound \u914d\u7f6e\n\n## \u6ce8\u610f\u4e8b\u9879\n\n- \u786e\u4fdd v2ray \u548c proxychains \u6240\u5728\u7684\u76ee\u5f55\u5df2\u7ecf\u6dfb\u52a0\u5230\u4e86 `PATH ` \u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u4f7f v2sub \u80fd\u591f\u627e\u5230\u5b83\u4eec\uff08\u5bf9\u4e8eWindows\uff0c\u5982\u679c\u901a\u8fc7 `v2sub install` \u5b89\u88c5\u7684\u8bdd\uff0c\u5219\u4e0d\u9700\u8981\uff09\n- \u5bf9\u4e8e Mac \u73af\u5883\uff0c\u7531\u4e8e SIP\uff08System Integrity Protection\uff09\u7279\u6027\uff0c\u4e00\u4e9b\u5728 `/usr/bin/` \u7b49\u76ee\u5f55\u4e2d\u7684\u547d\u4ee4\u4e0d\u80fd\u76f4\u63a5\u8d70\u4ee3\u7406\uff0c\u6bd4\u5982 `/usr/bin/curl`\u3002\u8fd9\u53ef\u4ee5\u7528\u547d\u4ee4\u5bf9\u5e94\u7684\u53c2\u6570\u6765\u6307\u5b9a\u4ee3\u7406\uff0c\u50cf `curl` \u53ef\u4ee5\u4f7f\u7528 `--proxy` \u6765\u6307\u5b9a\uff0c\u4e5f\u53ef\u4ee5\u8003\u8651\u8fdb `Recovery` \u6a21\u5f0f\u6267\u884c `csrutil disable` \u6765\u5c06 SIP \u7981\u6389\u3002\n\n## v2ray\u670d\u52a1\u542f\u52a8\u65b9\u5f0f\n\nv2sub \u6709\u4e24\u79cd\u542f\u52a8 v2ray \u670d\u52a1\u7684\u6a21\u5f0f\uff1a\n\n1. `v2sub node start `\uff08\u4e34\u65f6\u670d\u52a1\uff09\uff1a\u4e3b\u8981\u662f\u7ed9\u4e34\u65f6\u4f7f\u7528\u7684\uff0c\u4e0d\u8fc7\u5373\u4f7f `shell` \u9000\u51fa\u4e86\uff0c\u5b83\u4e5f\u4f1a\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u53ef\u4ee5\u901a\u8fc7 `v2sub node stop` \u505c\u6b62\n2. `v2sub service start`\uff08\u7cfb\u7edf\u670d\u52a1\uff09\uff1a\u4ee5\u7cfb\u7edf\u670d\u52a1\u65b9\u5f0f\u8fd0\u884c\uff0c\u8fd0\u884c\u524d\u9700\u8981\u901a\u8fc7 `v2sub service install` \u6765\u5b89\u88c5\u670d\u52a1\uff0c\u9ed8\u8ba4\u662f\u81ea\u542f\u52a8\u7684\uff0c\u5bf9\u4e8e Linux \u73af\u5883\uff0c\u53ea\u652f\u6301 `systemd` \u7c7b\u578b\u7684\u670d\u52a1\u7ba1\u7406\u5668\n\n## \u4f7f\u7528\u65b9\u6cd5\n\n> \u9664\u4e86\u4e0b\u9762\u8bf4\u660e\u5916\uff0c\u66f4\u591a\u4f7f\u7528\u65b9\u6cd5\u53ef\u76f4\u63a5\u770b `v2sub --help`\n\n### 1. \u521d\u59cb\u5316\u914d\u7f6e\n\n```bash\nv2sub init\n```\n\n\u8fd9\u4e00\u6b65\u662f\u5fc5\u987b\u7684\uff0c\u8fd9\u4f1a\u5728\u5bb6\u76ee\u5f55\u7684 `.v2sub` \u6587\u4ef6\u5939\u5185\u751f\u6210\u4e00\u4e2a\u521d\u59cb\u7684 v2ray \u914d\u7f6e\u6587\u4ef6 `base_config.json`\uff0c\u91cc\u9762\u6ca1\u6709 `outbounds` \u7684\u8bbe\u7f6e\uff0c\u5728\u5b9e\u9645\u542f\u52a8 v2ray \u7684\u65f6\u5019\uff0c\u4f1a\u6839\u636e\u8fd9\u4e2a\u6587\u4ef6\u751f\u6210\u5bf9\u5e94\u7684\u914d\u7f6e\u6587\u4ef6\u3002\n\n\u521d\u59cb\u5316\u4e4b\u540e\u53ef\u6839\u636e\u9700\u8981\u6267\u884c `v2sub config edit` \u6765\u5bf9\u914d\u7f6e\u6587\u4ef6\u8fdb\u884c\u4fee\u6539\uff0c\u914d\u7f6e\u6761\u76ee\u7684\u8bf4\u660e\u53ef\u4ee5\u770b\uff1a[v2ray \u914d\u7f6e\u6587\u4ef6](https://www.v2ray.com/chapter_02/)\uff0c\u4fee\u6539\u5b8c\u6210\u4e4b\u540e\uff0c\u5728 Linux \u548c Mac \u73af\u5883\u4e2d\u4f1a\u5bf9 v2ray \u670d\u52a1\u81ea\u52a8\u91cd\u542f\uff0c\u800c Windows \u9700\u8981\u624b\u52a8\u91cd\u542f\u3002\n\n### 2. \u8ba2\u9605\u8282\u70b9\u6216\u8005\u8282\u70b9\u5206\u7ec4\n\n```bash\n# \u6dfb\u52a0\nv2sub subscribe add <url>\n# \u66f4\u65b0\u5206\u7ec4\nv2sub subscribe update\nv2sub subscribe update --all\n# \u5220\u9664\u8282\u70b9\u6216\u5206\u7ec4\nv2sub subscribe delete\nv2sub subscribe delete --all\n# \u67e5\u770b\u8ba2\u9605\u5217\u8868\nv2sub subscribe show\n# \u7eaf\u89e3\u6790\u8282\u70b9\u6216\u5206\u7ec4\uff0c\u4e0d\u4f1a\u6dfb\u52a0\u5230\u5217\u8868\u4e2d\nv2sub subscribe parse <url>\n```\n\nurl \u53ef\u4ee5\u662f\u5355\u4e2a\u8282\u70b9\uff08\u6bd4\u5982\uff1a `ss://...`\uff09\uff0c\u4e5f\u53ef\u4ee5\u662f\u5206\u7ec4\u8ba2\u9605\u94fe\u63a5\uff08\u6bd4\u5982\uff1a`https://xxx.com/subscribe?token=xxx`\uff09\uff0c\u8ba2\u9605\u5206\u7ec4\u9700\u8981\u6267\u884c http \u8bf7\u6c42\uff0c\u5982\u679c\u7f51\u4e0d\u901a\u53ef\u4ee5\u6307\u5b9a\u53ef\u7528\u7684\u4ee3\u7406\n\n```bash\nv2sub subscribe --proxy <server:port> add <url>\n```\n\n### 3. \u9009\u62e9\u8282\u70b9\n\n\u5728\u542f\u52a8\u4e34\u65f6\u670d\u52a1\u6216\u8005\u5b89\u88c5\u7cfb\u7edf\u670d\u52a1\u524d\u90fd\u5f97\u5148\u9009\u62e9\u4e00\u4e2a\u8282\u70b9\u4ee5\u751f\u6210\u5bf9\u5e94\u7684 v2ray \u914d\u7f6e\u6587\u4ef6\uff0c\u8fd9\u4e24\u79cd\u6a21\u5f0f\u9009\u62e9\u8282\u70b9\u7684\u65b9\u6cd5\u5206\u522b\u662f\uff1a\n\n1. `v2sub node select`\n2. `v2sub service select`\n\n\u5982\u679c\u8ba2\u9605\u5217\u8868\u4e2d\u6709\u72ec\u7acb\u8282\u70b9\u548c\u5206\u7ec4\uff0c\u4f1a\u6709\u7c7b\u4f3c\u4e0b\u9762\u7684\u9009\u62e9\u63d0\u793a\uff1a\n\n```bash\n# anonymous\u5185\u662f\u72ec\u7acb\u8282\u70b9\u5217\u8868\uff0cgroups\u5219\u662f\u5206\u7ec4\u5217\u8868\nchoose subscribe type:\n \u00bb base config\n anonymous\n groups\n <Cancel>\n# base config \u6307\u7684\u662f\u76f4\u63a5\u590d\u7528\u9ed8\u8ba4\u7684base_config.json\u91cc\u9762\u7684\u8bbe\u7f6e\uff0c\u9ed8\u8ba4\u6ca1\u6709\u914d\u7f6e\u5e26proxy tag\u7684outbound\n# anonymous \u6307\u7684\u662f\u76f4\u63a5\u4ee5\u7c7b\u4f3c ss://...\uff0c\u8fd9\u79cd\u65b9\u5f0f\u6dfb\u52a0\u7684\u975e\u5206\u7ec4\u7684\u8ba2\u9605\u94fe\u63a5\n# groups \u6307\u7684\u662f\u8ba2\u9605\u5206\u7ec4\n```\n\n**notes: **\u5728\u670d\u52a1\u542f\u52a8\u4e4b\u540e\u4e5f\u53ef\u4ee5\u91cd\u65b0\u6267\u884c `select` \u6765\u5207\u6362\u8282\u70b9\n\n### 4. \u542f\u52a8\u4e34\u65f6\u670d\u52a1\n\n```bash\n# \u542f\u52a8\nv2sub node start\n# \u505c\u6b62\nv2sub node stop\n# \u91cd\u542f\nv2sub node restart\n# \u67e5\u770b\u8fd0\u884c\u72b6\u6001\nv2sub node status\n# \u5207\u6362\u8282\u70b9\nv2sub node select\n```\n\n\u9ed8\u8ba4\u7aef\u53e3\u53f7\uff1a\n\n- sock5: 23338\n- http: 23339\n\n### 5. \u5b89\u88c5\u548c\u542f\u52a8 v2sub \u7cfb\u7edf\u670d\u52a1\n\n```bash\n# \u5b89\u88c5\u670d\u52a1\uff08Windows\u73af\u5883\u8fd9\u4e00\u6b65\u9700\u8981\u7f16\u8bd1\u670d\u52a1\uff0c\u53ef\u80fd\u9700\u8981\u4e9b\u65f6\u95f4\uff09\nv2sub service install\n# \u542f\u52a8\u670d\u52a1\nv2sub service start\n# \u505c\u6b62\u670d\u52a1\nv2sub service stop\n# \u91cd\u542f\nv2sub service restart\n# \u67e5\u770b\u670d\u52a1\u8fd0\u884c\u72b6\u6001\nv2sub service status\n# \u5207\u6362\u8282\u70b9\nv2sub service select\n# \u5378\u8f7d\u670d\u52a1\nv2sub service uninstall\n```\n\n\u9ed8\u8ba4\u7aef\u53e3\u53f7\uff1a\n\n- sock5: 22338\n- http: 22339\n\n### 6. \u5e94\u7528\u4ee3\u7406\n\n#### a. shell \u5185\u4e34\u65f6\u751f\u6548\n\n```bash\n# linux shell\nexport http_proxy='http://127.0.0.1:<\u7aef\u53e3\u53f7>'\nexport https_proxy='http://127.0.0.1:<\u7aef\u53e3\u53f7>'\n\n# powershell\n$env:http_proxy='http://127.0.0.1:<\u7aef\u53e3\u53f7>'\n$env:https_proxy='http://127.0.0.1:<\u7aef\u53e3\u53f7>'\n\n# cmd\nset http_proxy=http://127.0.0.1:<\u7aef\u53e3\u53f7>\nset https_proxy=http://127.0.0.1:<\u7aef\u53e3\u53f7>\n```\n\n#### b. proxychains \u522b\u540d\n\n```bash\n# \u6267\u884c\u540e\u4f1a\u63d0\u793a\u4f60\u9009\u62e9\u5e94\u7528\u7684\u662f\u4e34\u65f6\u670d\u52a1\u8fd8\u662f\u7cfb\u7edf\u670d\u52a1\u6a21\u5f0f\uff0c\u5e76\u63d0\u4f9b\u522b\u540d\nv2sub proxychains alias\n# \u5220\u9664\u522b\u540d\nv2sub proxychains alias --delete <\u522b\u540d>\n# \u663e\u793a\u6240\u6709\u522b\u540d\nv2sub proxychains alias --list-all\n```\n\n\u521b\u5efa\u522b\u540d\u4e4b\u540e\uff0c\u5728 Windows \u73af\u5883\u9700\u8981\u91cd\u542f\u4f60\u7684 powershell \u6216\u8005 cmd\uff0cLinux \u6216 Mac \u9700\u8981\u6267\u884c `source <shell\u914d\u7f6e\u6587\u4ef6>` \u6765\u4f7f\u522b\u540d\u751f\u6548\u3002\n\n\u8fd9\u53ea\u662f\u521b\u5efa\u4e00\u4e2a proxychains \u7684\u914d\u7f6e\u6587\u4ef6\u548c\u547d\u4ee4\u522b\u540d\uff0c\u4e0d\u4f1a\u5bf9 v2ray \u670d\u52a1\u8fd0\u884c\u6709\u5f71\u54cd\uff0c\u4f7f\u7528\u7684\u65f6\u5019\u8981\u786e\u4fdd\u5bf9\u5e94\u7684\u670d\u52a1\u8fd0\u884c\u4e2d\u3002\n\n```bash\n# \u6bd4\u5982\u521b\u5efa\u4e86\u4e00\u4e2a\u522b\u540d\u4e3avproxy\uff0c\u5728\u786e\u4fdd\u5bf9\u5e94\u7684\u670d\u52a1\u8fd0\u884c\u540e\uff0c\u53ef\u4ee5\u8fd9\u6837\u4f7f\u7528\nvproxy curl https://ipinfo.io/ip\n```\n\n#### c. \u7cfb\u7edf\u4ee3\u7406\u8bbe\u7f6e\n\n\u5bf9\u4e8e Windows \u548c Mac \u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u542f\u7528\u6216\u7981\u7528\u7cfb\u7edf\u4ee3\u7406\u8bbe\u7f6e\uff0cWindows \u662f\u4fee\u6539 IE \u7684 http \u4ee3\u7406\u8bbe\u7f6e\uff0cMac \u5219\u662f\u4fee\u6539\u7f51\u7edc\u63a5\u53e3\u7684 http \u548c socks \u8bbe\u7f6e\u3002\u5bf9\u4e8e Linux\uff0c\u7531\u4e8e\u53d1\u884c\u7248\u4f17\u591a\uff0cv2sub \u7684\u76ee\u6807\u4e5f\u4e0d\u662f\u684c\u9762\u73af\u5883\uff0c\u6240\u4ee5\u4e0d\u63d0\u4f9b\u8fd9\u4e2a\u8bbe\u7f6e\uff0c\u6709\u9700\u8981\u7684\u8bdd\u624b\u52a8\u8bbe\u7f6e\u3002\n\n```bash\n# \u542f\u7528\nv2sub config proxy enable\n# \u7981\u7528\nv2sub config proxy disable\n```\n\n#### d. \u5141\u8bb8\u5c40\u57df\u7f51\u8fde\u63a5\n\n\u4f7f\u7528\u4ee5\u4e0b\u4e24\u4e2a\u547d\u4ee4\u53ef\u4ee5\u5141\u8bb8\u6216\u7981\u6b62\u5176\u5b83\u673a\u5668\u8fde\u63a5\u5bf9\u5e94\u7684\u4ee3\u7406\u670d\u52a1\uff0c\u4e3a\u4e86\u5b89\u5168\u8d77\u89c1\uff0c\u4fee\u6539\u4e4b\u540e\u8bf7\u624b\u52a8\u6dfb\u52a0\u6216\u5220\u9664\u9632\u706b\u5899\u89c4\u5219\u3002\n\n```bash\n# \u5141\u8bb8\nv2sub config lan allow\n# \u7981\u6b62\nv2sub config lan disallow\n```\n\n### 7. \u8def\u7531\u89c4\u5219\u8bbe\u7f6e\n\n```bash\n# \u53ef\u4ee5\u7528\u4ee5\u4e0b\u547d\u4ee4\u7ba1\u7406direct\u6216block\u8def\u7531\u89c4\u5219\n\n# \u6dfb\u52a0direct\u89c4\u5219\nv2sub config direct add\n# \u5220\u9664direct\u89c4\u5219\nv2sub config direct remove\n# \u67e5\u770bdirect\u89c4\u5219\nv2sub config direct list\n\n# \u6dfb\u52a0block\u89c4\u5219\nv2sub config block add\n# \u5220\u9664block\u89c4\u5219\nv2sub config block remove\n# \u67e5\u770bblock\u89c4\u5219\nv2sub config block list\n```\n\n## Plugin\n\n\u53ef\u4ee5\u5728 `~/.v2sub/plugins` \u76ee\u5f55\u4e2d\uff0c\u6dfb\u52a0\u81ea\u5b9a\u4e49\u7684 python \u811a\u672c\uff0cv2sub \u5728\u521d\u59cb\u5316\u65f6\u4f1a\u81ea\u52a8\u52a0\u8f7d\u91cc\u9762\u7684\u6240\u6709\u811a\u672c\u3002\u8fd9\u4e3b\u8981\u662f\u4e3a\u4e86\u80fd\u81ea\u5b9a\u4e49\u89e3\u6790\u4e00\u4e9b\u9664\u4e86 v2sub \u672c\u6765\u4e0d\u652f\u6301\u7684\u5176\u5b83\u534f\u8bae\uff0c\u5bf9\u4e8e ss\u3001trojan\u3001vmess \u8fd9\u4e9b v2sub \u672c\u6765\u652f\u6301\u7684\u534f\u8bae\uff0c\u5982\u679c\u5728\u89e3\u6790\u6216\u8005\u751f\u6210\u914d\u7f6e\u6587\u4ef6\u6709\u95ee\u9898\uff0c\u4e5f\u53ef\u4ee5\u5728\u6269\u5c55\u4e2d\u5c06\u539f\u672c\u7684\u89e3\u6790\u65b9\u6cd5\u7ed9\u66ff\u6362\u6389\u3002\n\n```python\n# \u6269\u5c55\u4f8b\u5b50 ~/.v2sub/plugins/hh.py\n\nimport re\n\nfrom urllib.parse import urlparse, unquote, ParseResult\n\nfrom v2raysub import cli as v2cli, protocol, util\n\n# \u7ed9 v2sub \u6dfb\u52a0\u4e86\u4e24\u4e2a\u65b0\u547d\u4ee4\n# \u53ef\u4ee5\u7528 v2sub foo \u548c v2sub bar \u6765\u8c03\u7528\u8fd9\u4e24\u4e2a\u547d\u4ee4\n@v2cli.cli.command(\"foo\")\ndef foo():\n print('foo command')\n\n\n@v2cli.cli.command(\"bar\")\ndef bar():\n print('bar command')\n\n# \u89e3\u6790 hh://...\ndef parse_hh(url: ParseResult) -> object:\n result = {'success': 0}\n\n url = urlparse(f'hh://{protocol.regular_content(url)}')\n pattern = r'^(?P<password>.+)@(?P<server>.+):(?P<port>\\d+)$'\n\n match = re.match(pattern, url.netloc)\n if match is None:\n result['reason'] = 'invalid hoohoo params'\n return result\n\n result['success'] = 1\n result['protocol'] = 'hoohoo'\n result['remark'] = unquote(url.fragment)\n result['server'] = match['server']\n result['port'] = match['port']\n result['identify'] = match['password']\n result['method'] = 'chacha20'\n result['options'] = util.parse_query_string(url.query)\n\n return result\n\n\n# \u4e3a hoohoo \u8fd9\u4e2a\u5047\u7684\u534f\u8bae\u751f\u6210 v2ray \u914d\u7f6e\u6587\u4ef6\ndef generate_hoohoo_outbound(config, node, node_info, node_options) -> object:\n config['settings']['servers'] = [{\n 'address': node_info['server'],\n 'method': node_info['method'],\n 'ota': False,\n 'password': node_info['identify'],\n 'port': int(node_info['port'])\n }]\n config['streamSettings'] = {\n \"network\": \"tcp\"\n }\n\n if node_options.get('tls', '0') == '1':\n config['streamSettings']['security'] = 'tls'\n\n return config\n\n\n# init_plugin \u4f1a\u88ab v2sub \u81ea\u52a8\u8c03\u7528\ndef init_plugin(app):\n # \u6ce8\u518c url \u89e3\u6790\u5668\n protocol.register_parser('hh', parse_hh)\n # \u6ce8\u518c\u914d\u7f6e\u6587\u4ef6\u751f\u6210\u5668\n protocol.register_generator('hoohoo', generate_hoohoo_outbound)\n\n```\n\n\n\n\n\n",
"bugtrack_url": null,
"license": "Apache License, Version 2.0",
"summary": "subscription and config generation tool for v2ray",
"version": "0.3.1",
"project_urls": {
"Homepage": "https://github.com/12CrazyPaul21/v2raysub",
"Source": "https://github.com/12CrazyPaul21/v2raysub"
},
"split_keywords": [
"v2ray",
" config",
" subscribe",
" proxy",
" proxychains"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0265cafbf3c4c7d7d80341bb0ebd4c8ad81a68addb7c425f113eced5c6ff062c",
"md5": "eb0d746bf4de95869e566665a8ab8a23",
"sha256": "37c9832581887b1b08a552fec0dee2ed3aed7f92159c804465e575d725a114ad"
},
"downloads": -1,
"filename": "v2raysub-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "eb0d746bf4de95869e566665a8ab8a23",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 36069,
"upload_time": "2024-08-26T11:54:26",
"upload_time_iso_8601": "2024-08-26T11:54:26.531413Z",
"url": "https://files.pythonhosted.org/packages/02/65/cafbf3c4c7d7d80341bb0ebd4c8ad81a68addb7c425f113eced5c6ff062c/v2raysub-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5bb80f423b79a523b0c4d5457b1c09e85c7050827c0dcc278c9330c233a8565d",
"md5": "f08655254bc36e8f42442cd605adfadc",
"sha256": "dc7ad30560721847bd973bf51682b189b3ff9e84e560cac979eb704ca1c463ee"
},
"downloads": -1,
"filename": "v2raysub-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "f08655254bc36e8f42442cd605adfadc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 43341,
"upload_time": "2024-08-26T11:54:27",
"upload_time_iso_8601": "2024-08-26T11:54:27.526954Z",
"url": "https://files.pythonhosted.org/packages/5b/b8/0f423b79a523b0c4d5457b1c09e85c7050827c0dcc278c9330c233a8565d/v2raysub-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-26 11:54:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "12CrazyPaul21",
"github_project": "v2raysub",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "v2raysub"
}