Giter Site home page Giter Site logo

v2sub's Introduction

v2sub

linux 上面 v2ray 订阅管理工具, 支持获取 vmess 订阅

帮助自己在 linux 上面订阅 JustMySocks

v2sub 是命令行工具,支持在 linux 下命令行运行,也可以交叉编译之后直接放在软路由里面跑, 如果想要在更加方便的进行远程控制的话,推荐使用带有 http api 的 v2sub-w

功能支持

订阅管理:
    -sub add {name} {url} 
        添加一个订阅,订阅节点自动增加到 ser list
    -sub update {name} 
        更新一个订阅
    -sub customer {sub_name} {customer_result} 
        手动更新一个订阅, customer_result 是 sub 地址返回的加密字符串
    -sub update all 
        更新全部订阅结果
    -sub remove {name} 
        删除一个订阅
    -sub list 
        查看当前所有订阅

节点查看:
    -ser list 
        查看所有节点
    -ser set {ser_id} 
        设置默认节点
    -ser setx 
        对节点进行 ping 测速,之后将默认节点设置为最快节点
    -ser setflush
        将当前选择的节点输出到 /etc/v2sub/config.json
    -ser speedtest
        使用 tcping 查看各个节点的连接速度
    
连接配置管理
    -conf sport {socket_port} 
        socket 端口号管理, 默认 1080
    -conf hport {http_port} 
        http 端口号管理, 默认1081
    -conf lconn {true|false} 
        是否允许来自局域网的连接,默认为 false
    -conf list
        展示当前的 port、lconn 配置
  
连接
    -conn start 
        启用 v2ray 连接 server    
    -conn start-pac
        启用 v2ray 连接 server,并同时在 :23333/v2sub.pac 返回 /etc/v2sub/v2sub.pac 文件
    -conn kill 
        停止 v2ray (kill 掉其他 v2sub 和 v2ray)

其他
    -v, --version
        查看版本号
    -h, --help
        查看帮助说明

使用说明

请确保已安装 v2ray 到 /usr/local/bin/v2ray (v2fly 安装脚本默认安装位置)

先使用 go build v2sub.go 编译得到运行文件 ./v2sub

# 添加一个订阅, 添加后会自动获取 vmess 连接设置
./v2sub -sub add 订阅别名 http://xxx.xxx.xxxxx?xxx

# 查看当前已有订阅列表
./v2sub -sub list
#=======================================================
#name       url
#订阅别名    http://xxx.xxx.xxxxx?xxx
#=======================================================

# 查看当前可用的服务器节点, [0] 代表这是默认连接节点
./v2sub -ser list
#=======================================================
#ID   别名                                               地址                     端口       类型
#[0]  [email protected]:11111                          xxx.xxx.xxx.xxx         52623      tcp
# 1   [email protected]:11111                          xxx.xxx.xxx.xxx         52623      tcp
# 2   [email protected]:11111                          xxx.xxx.xxx.xxx         52623      tcp
# 3   [email protected]:11111                          xxx.xxx.xxx.xxx         52623      tcp
#=======================================================

# 设置默认连接节点
./v2sub -ser set 2
#=======================================================
#ID   别名                                               地址                     端口       类型
# 0   [email protected]:11111                          xxx.xxx.xxx.xxx         52623      tcp
# 1   [email protected]:11111                          xxx.xxx.xxx.xxx         52623      tcp
#[2]  [email protected]:11111                          xxx.xxx.xxx.xxx         52623      tcp
# 3   [email protected]:11111                          xxx.xxx.xxx.xxx         52623      tcp
#=======================================================

# 查看当前连接配置, 包括 socks 端口 / http 端口 / 局域网连接
./v2sub -conf list
#[v2sub-INFO] [0803-205402] Config SocksPort:       1080
#[v2sub-INFO] [0803-205402] Config HttpPort:        1081
#[v2sub-INFO] [0803-205402] Config AllLocalConnect: false

# 将 http 代理端口设置为 10800
./v2sub -conf hport 10800
# 允许来自局域网的设备连接代理
./v2sub -conf lconn true

# 杀死当前正在运行的 v2ray 和 v2sub 程序
./v2sub -conn kill

# 调用 /usr/local/bin/v2ray 程序连接刚刚设置节点
./v2sub -conn start

配置文件生成

v2ray 的配置文件由模板 json 生成,可自己修改模板 json 来设置路由等信息

模板 json 在第一次运行之后会输出到 /etc/v2sub/config_module.json

定时订阅脚本

首先将 v2sub 移动到 /ush/bin

可用以下脚本做开机自启 / cron 定时任务

#!/bin/bash

# 更新全部订阅结果
v2sub -sub updateall

# 节点测速 + 设置最快节点
v2sub -ser setx

# 杀掉当前正在运行的 v2sub / v2ray
v2sub -conn kill

# 启动 v2ray 连接
v2sub -conn start

v2sub's People

Contributors

ericwyn avatar wgliyuli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

v2sub's Issues

The -c flag moved to run subcommand in new version of v2ray(v2fly version)

Please consider make a compatibility
The new version of v2ray command line has a new run subcommand

V2Ray 5.7.0 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.20.4 linux/amd64)
A unified platform for anti-censorship.

(base) ➜  v2sub git:(main) ./v2sub -conn start         
[v2sub-INFO] [1002-012905] load config msg success
[v2sub-INFO] [1002-012905] start v2ray ......
[v2sub-INFO] [1002-012905] use config is :   ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 
[v2sub-INFO] [1002-012905] ========================================================================
[v2sub-INFO] [1002-012905] ID  别名                                              地址                    端口      类型 
[v2sub-INFO] [1002-012905]  1  ***              192.***.***.***         18950     none 
[v2sub-INFO] [1002-012905] ========================================================================
[v2sub-INFO] [1002-012905] v2ray config path : /etc/v2sub/config.json


flag provided but not defined: -config
Usage of /usr/local/bin/v2ray:
[v2sub-ERR ] [1002-012905] run command error[/usr/local/bin/v2ray -c /etc/v2sub/config.json]
[v2sub-ERR ] [1002-012905] exit status 2

Run with the command is OK

(base) ➜  v2sub git:(main) ✗ /usr/local/bin/v2ray run -c /etc/v2sub/config.json
V2Ray 5.7.0 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.20.4 linux/amd64)
A unified platform for anti-censorship.
2023/10/02 01:41:28 [Warning] V2Ray 5.7.0 started

base64 decode fail

[v2sub-ERR ] [0804-221908] base64 decode fail
[v2sub-ERR ] [0804-221908]

Invalid parameters

[v2sub-ERR ] [0804-221908] parse sub msg error, subMsg:

Invalid parameters

panic: decode base64 fail while parse sub msg

goroutine 1 [running]:
github.com/Ericwyn/v2sub/sub.checkSub.func1(0xc000245800)
/root/v2sub/sub/sub_mgr.go:224 +0xf6
github.com/Ericwyn/v2sub/ajax.Send({{0xc000281140, 0x34}, {0x80172f, 0x3}, 0x0, 0x0, {0x0, 0x0}, 0x0, 0xc0001cdf80, ...})
/root/v2sub/ajax/ajax.go:132 +0x967
github.com/Ericwyn/v2sub/sub.checkSub({{0x7ffd5973f3fe?, 0x4?}, {0x7ffd5973f3f2?, 0x2?}})
/root/v2sub/sub/sub_mgr.go:216 +0x178
github.com/Ericwyn/v2sub/sub.AddSub({0x7ffd5973f3f2, 0xb}, {0x7ffd5973f3fe, 0x34})
/root/v2sub/sub/sub_mgr.go:69 +0x16c
github.com/Ericwyn/v2sub/sub.ParseArgs({0xc0000b0020?, 0x3, 0x3})
/root/v2sub/sub/sub_mgr.go:25 +0x15c
main.parseArg({0xc0000b0010?, 0xc0000021a0?, 0xc00021ff70?})
/root/v2sub/v2sub.go:41 +0xc7
main.main()
/root/v2sub/v2sub.go:29 +0xc6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.