v2raypool

package module
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 41 Imported by: 0

README

简介

  • 同时接入多个v2ray节点,使用多个本地端口,组成简单的IP代理池服务。可供爬虫等程序调用。

  • 可以选一个节点设为系统代理,作为普通的v2ray客户端使用。

  • 提供通用gRPC控制接口,参看数据定义文件 v2raypool.proto

项目文档

WebUI面板

Windows代理设置: 网络和Internet -> 代理 -> 手动设置代理

使用说明

不想自己编译项目源码,可下载Release压缩包直接使用,再看第4-5步的使用说明。

1. 下载依赖

运行命令: go mod tidy

1.1 如因网络问题下载失败,可设置模块代理。运行命令:

go env -w GOPROXY=https://goproxy.cn,direct
# 或者 go env -w GOPROXY=https://goproxy.io,direct

1.2 若出现依赖包版本冲突,请删除 go.mod 文件,再运行命令:

go mod init github.com/iotames/v2raypool
go mod tidy

2. 编译可执行文件

2.1 编译

# 进入项目 main 目录,并执行go编译命令
cd main

# linux或mac 运行: go build -o v2raypool -trimpath -ldflags "-s -w -buildid=" .
go build -o v2raypool.exe -trimpath -ldflags "-s -w -buildid=" .

编译出二进制可执行文件 v2raypool(linux or max) 或 v2raypool.exe(windows)

2.2 生成配置文件

命令行运行可执行文件(v2raypool.exe 或 ./v2raypool),会生成配置文件 .env。并提示找不到v2ray核心文件:

v2raypool.exe
请检查配置文件,路径:(.env)
VP_V2RAY_PATH 配置项错误,找不到可执行文件。
请下载v2ray核心文件(https://github.com/v2fly/v2ray-core/releases)

3. 下载v2ray核心文件

3.1 官网下载核心文件Zip压缩包: https://github.com/v2fly/v2ray-core/releases

3.2 解压到 main/bin 目录,并删除或改名解压后的 config.json 文件,防止程序错误读取。

3.3 检查或修改v2ray 可执行文件路径: 查看 .env 配置文件的 VP_V2RAY_PATH 配置项。

4. 设置订阅地址

设置代理节点的订阅源地址,请更改 .env 文件的 VP_SUBSCRIBE_URL 配置项,配置值为http网络地址。

若网络地址访问异常,可使用 VP_SUBSCRIBE_DATA_FILE 配置项。设法查看订阅地址的响应结果,并存入文件 subscribe_data.txt

5. 运行服务端和客户端

5.1 服务端

可执行文件直接运行,会启动 gRPCWebUI 服务端。 如果是首次运行,会自动生成 .envdefault.env 配置文件。

# linux 或 mac 执行 ./v2raypool
v2raypool.exe

5.2 客户端

gRPC 客户端交互命令:

# 启动v2ray代理池
v2raypool.exe --startproxynodes

# 查看v2ray代理池信息(包括:本地代理端口号,测速结果,运行状态,测速时间,节点名,节点索引)
v2raypool.exe --getproxynodes

# 测速(测速基准使用https://www.google.com)。测速结束后,会自动选择最快的节点作为系统代理节点。
v2raypool.exe --testproxynodes

# 指定已测速过的域名,按速度从快到慢,查看代理节点信息
v2raypool.exe --getproxynodesbydomain=www.google.com

# 根据索引值激活某个节点为系统代理的端口(--getproxynodes 查看索引值,系统代理端口从VP_HTTP_PROXY的值读取)
v2raypool.exe --activeproxynode=16

# 停止所有节点
v2raypool.exe --stopproxynodes

WebUI 网页面板: http://127.0.0.1:8087

6. Linux配置systemd系统服务(可选)

Linux平台通过配置 v2raypool.service ,可使用 systemctl 系统命令来管理 v2raypool。 可使用环境变量 VP_ENV_FILE 定义配置文件的路径。不设置默认为 .env

  1. 新建 v2raypool.service 文件:
vim /usr/lib/systemd/system/v2raypool.service

v2raypool.service内容示例(/root/v2raypool/main 为可执行文件所在路径):

[Unit]
Description=v2ray proxy pool
After=network.target

[Service]
WorkingDirectory=/root/v2raypool/main
ExecStart=/root/v2raypool/main/v2raypool
User=root
Restart=on-failure
RestartSec=300
# KillSignal=SIGQUIT
TimeoutStopSec=10
StandardOutput=file:/root/v2raypool/main/output.log
StandardError=file:/root/v2raypool/main/output.err.log

[Install]
WantedBy=multi-user.target
  1. 重载systemd配置
systemctl daemon-reload
  1. 使用 systemctl 管理v2raypool的gRPC服务端
systemctl status v2raypool
systemctl start v2raypool
systemctl stop v2raypool

配置说明

main 目录编译生成可执行文件,首次运行会生成2个文件:

  • default.env: 显示所有配置项的默认值,不应修改此文件。
  • .env: 程序配置文件。更改后可覆盖 default.env 文件中的默认值。
# 该目录存放程序运行时产生的文件
VP_RUNTIME_DIR = "runtime"

# 傻瓜模式。当配置满足条件时,应用启动后,自动运行所有节点,执行测速,并设置速度最快的节点为系统代理。
# 适合打包现成的配置和应用,直接分享给小白用。
VP_AUTO_START = true

# Web服务器端口。设置为0可禁用Web面板
VP_WEB_SERVER_PORT = 8087

# 代理池的gRPC服务端口
VP_GRPC_PORT = 50051

# v2ray可执行文件路径
# 例: "D:\\Users\\yourname\\v2ray-windows-64\\v2ray.exe" or "/root/v2ray-linux64/v2ray"
VP_V2RAY_PATH = "bin/v2ray.exe"

# 代理节点订阅地址
# 支持 http:// 和 socks5:// 协议
VP_SUBSCRIBE_URL = ""

# 若订阅地址无法直接访问,可指定订阅数据文件,数据文件内容为访问订阅地址获取的原始数据。
# 若有设置订阅数据文件,且文件内容不为空。则优先从该文件读取订阅节点信息。
VP_SUBSCRIBE_DATA_FILE = "subscribe_data.txt"

# 设置HTTP代理,代理池每个节点的本地端口号,往后开始累加。为防止与常用端口冲突,尽量设大点。
VP_HTTP_PROXY = "http://127.0.0.1:30000"

# 节点测速的URL
VP_TEST_URL = "https://www.google.com"

订阅节点

数据格式

  1. VP_SUBSCRIBE_URL: 订阅地址配置。填写 http 开头的URL网址。

  2. base64订阅数据: 访问订阅地址得到的原始数据。数据被BASE64加密,可保存为 subscribe_data.txt 文件,并配置 VP_SUBSCRIBE_DATA_FILE 选项。

base64订阅数据 经过 base64解码 后,得到以 \n 换行符分割的多个代理节点信息。暂时仅支持 vmess 协议的节点。 每个节点信息,可能都被Base64加密过(vmess://),也可能是明文(vless://),或者二者混合(ss://)。如下所示:

vmess://eyJhZGQiOiAiMjAyLjc4LjE2Mi41IiwgImFpZCI6IDAsICJob3N0IjogImlyc29mdC5zeXRlcy5uZXQiLCAiaWQiOiAiMmZmOTdjNmQtODU1Ny00MmE0LWI0M2YtMTljNzdjNTk1OWVhIiwgIm5ldCI6ICJ3cyIsICJwYXRoIjogIi9AZm9yd2FyZHYycmF5IiwgInBvcnQiOiA0NDMsICJwcyI6ICJnaXRodWIuY29tL2ZyZWVmcSAtIFx1NTM3MFx1NWVhNiAgMiIsICJ0bHMiOiAidGxzIiwgInR5cGUiOiAiYXV0byIsICJzZWN1cml0eSI6ICJhdXRvIiwgInNraXAtY2VydC12ZXJpZnkiOiB0cnVlLCAic25pIjogIiJ9
vless://26DL68CE-DL93-8342-LQ8F-317F4A6E7J76@45.43.31.159:443?encryption=none&security=reality&sni=azure.microsoft.com&fp=safari&pbk=c7qU9-_0WflwIKUiZFxSss_xw-2AP3jB1ENxKLI0OTw&type=tcp&headerType=none#u9un-US-Xr1
ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTozNlpDSGVhYlVTZktqZlFFdko0SERW@185.242.86.156:54170#github.com/freefq%20-%20%E4%BF%84%E7%BD%97%E6%96%AF%20%201
ss://YWVzLTI1Ni1nY206N0JjTGRzTzFXd2VvR0QwWA@193.243.147.128:40368#github.com/freefq%20-%20%E6%B3%A2%E5%85%B0%20%205
vmess://eyJhZGQiOiAic2VydmVyMzEuYmVoZXNodGJhbmVoLmNvbSIsICJhaWQiOiAwLCAiaG9zdCI6ICJzZXJ2ZXIzMS5iZWhlc2h0YmFuZWguY29tIiwgImlkIjogIjQxNTQxNDNjLWJiYmEtNDdhNC05Zjc5LWMyZWQwODdjYmNjOSIsICJuZXQiOiAid3MiLCAicGF0aCI6ICIvIiwgInBvcnQiOiA4ODgwLCAicHMiOiAiZ2l0aHViLmNvbS9mcmVlZnEgLSBcdTdmOGVcdTU2ZmRDbG91ZEZsYXJlXHU1MTZjXHU1M2Y4Q0ROXHU4MjgyXHU3MGI5IDYiLCAidGxzIjogIiIsICJ0eXBlIjogImF1dG8iLCAic2VjdXJpdHkiOiAiYXV0byIsICJza2lwLWNlcnQtdmVyaWZ5IjogdHJ1ZSwgInNuaSI6ICIifQ==
  1. 系统会忽略格式错误或解析失败的节点,然后继续解析下个节点。

  2. vmess 节点信息再次经过 BASE64解码 后,解析为JSON字符串格式。如下所示:

{"add":"us0.xxx.top","host":"","id":"93EA57CE-EA21-7240-EE7F-317F4A6A8B65","net":"ws","path":"","port":"444","ps":"xxx-v2-US-LosAngeles0","tls":"","type":"none","v":2,"aid":0}

如下节点会解析失败:

ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTozNlpDSGVhYlVTZktqZlFFdko0SERW@185.242.86.156:54170#github.com/freefq%20-%20%E4%BF%84%E7%BD%97%E6%96%AF%20%201

调试工具

路由规则

支持自定义域名和IP列表配置:

  • PROXY_DOMAIN_LIST 代理域名列表
  • DIRECT_DOMAIN_LIST 直连域名列表
  • PROXY_IP_LIST 代理IP列表
  • DIRECT_IP_LIST 直连IP列表

域名匹配规则:

  • 纯字符串:当此字符串匹配目标域名中任意部分,该规则生效。比如 sina.com 可以匹配 sina.comsina.com.cnsina.companywww.sina.com,但不匹配 sina.cn
  • 正则表达式:由 regexp: 开始,余下部分是一个正则表达式。当此正则表达式匹配目标域名时,该规则生效。例如 regexp:\.goo.*\.com$ 匹配 www.google.comfonts.googleapis.com,但不匹配 google.com
  • 子域名(推荐):由 domain: 开始,余下部分是一个域名。当此域名是目标域名或其子域名时,该规则生效。例如 domain:v2ray.com 匹配 www.v2ray.comv2ray.com,但不匹配 xv2ray.com
  • 完整匹配:由 full: 开始,余下部分是一个域名。当此域名完整匹配目标域名时,该规则生效。例如 full:v2ray.com 匹配 v2ray.com 但不匹配 www.v2ray.com
  • 预定义域名列表:由 geosite: 开头,余下部分是一个类别名称(域名列表),如 geosite:google 或者 geosite:cn。名称及域名列表参考预定义域名列表
  • 从文件中加载域名:形如 ext:file:tag,必须以 ext: 开头,后面跟文件名和标签,文件存放在资源目录中,文件格式与 geosite.dat 相同,标签必须在文件中存在。

IP匹配规则:

  • IP:形如 127.0.0.1
  • CIDR:形如 10.0.0.0/8
  • GeoIP: 形如 geoip:cn 为正向匹配,即为匹配「中国大陆 IP 地址」。后面跟双字符国家或地区代码,支持所有可以上网的国家和地区。

形如 geoip:!cn 为反向匹配,即为匹配「非中国大陆 IP 地址」。后面跟双字符国家或地区代码,支持所有可以上网的国家和地区。

特殊值:geoip:private(V2Ray 3.5+),包含所有私有地址,如 127.0.0.1

  • 从文件中加载 IP: 形如 ext:file:tagext-ip:file:tag 为正向匹配,即为匹配 「tag 内的 IP 地址」。

形如 ext:file:!tagext-ip:file:!tag 为反向匹配,即为匹配「非 tag 内的 IP 地址」。

必须以 ext:ext-ip: 开头,后面跟文件名、标签!标签,文件存放在资源目录中,文件格式与 geoip.dat 相同,标签必须在文件中存在。

具体请参看 v2ray路由规则

开发相关

gRPC接口

  1. 使用proto数据格式定义文件: ./v2raypool.proto 可实现跨语言调用
  2. Go语言的gRPC接口文件位于 ./grpc 目录。引用包名: github.com/iotames/v2raypool/grpc
  3. 调用过程参考代码文件: ./main/main_grpc.go
# 从proto数据格式文件生成可供Go语言调用的代码包
protoc --go_out=./ --go-grpc_out=./ v2raypool.proto

Documentation

Index

Constants

View Source
const MAX_TEST_DURATION = 5 * time.Second

节点测速最大超时设置。

View Source
const ROUTING_RULES_FILE = "routing.rules.json"

若存在,则优先读取。否则创建(v2raypool)

View Source
const TAG_INBOUND_API = "TAG_INBOUND_API"
View Source
const TAG_OUTBOUND_ACTIVE = "TAG_ACTIVE_OUTBOUND"
View Source
const TAG_OUTBOUND_API = "TAG_OUTBOUND_API"
View Source
const TAG_OUTBOUND_DIRECT = "DIRECT"
View Source
const V2RAYPOOL_CONFIG_FILE = "v2raypool.config.json"
View Source
const V2RAY_CONFIG_FILE = "v2ray.config.json"

只写文件,被 ROUTING_RULES_FILE 文件覆盖部分值(v2raypool)

Variables

This section is empty.

Functions

func Base64StdDecode

func Base64StdDecode(s string) (string, error)

封装base64.StdEncoding进行解码,加入了长度补全,换行删除。当error时,返回输入和err

func Base64URLDecode

func Base64URLDecode(s string) (string, error)

封装base64.URLEncoding进行解码,加入了长度补全,换行删除。当error时,返回输入和err

func ChangeProxyNode

func ChangeProxyNode() error

ChangeProxyNode 更换一个可用节点

func NewProxyPoolGrpcClient

func NewProxyPoolGrpcClient() (c g.ProxyPoolServiceClient, conn *grpc.ClientConn)

NewProxyPoolGrpcClient c, conn := NewProxyPoolGrpcClient() defer conn.Close() ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() nds, err := c.GetProxyNodes(ctx, &ProxyNode{IsRunning: true})

func RequestProxyPoolGrpcOnce

func RequestProxyPoolGrpcOnce(h func(c g.ProxyPoolServiceClient, ctx context.Context))

func RunProxyPoolGrpcServer

func RunProxyPoolGrpcServer()

func RunServer added in v1.1.3

func RunServer()

func SetProxy added in v1.2.0

func SetProxy(proxy string) error

Types

type JsonConfig added in v1.3.0

type JsonConfig struct {
	// contains filtered or unexported fields
}

func NewJsonConfig added in v1.3.0

func NewJsonConfig(b []byte) *JsonConfig

func NewJsonConfigFromFile added in v1.3.0

func NewJsonConfigFromFile(fpath string) *JsonConfig

func (JsonConfig) Decode added in v1.3.0

func (j JsonConfig) Decode(v any) error

func (JsonConfig) GetFilepath added in v1.3.0

func (j JsonConfig) GetFilepath() string

func (JsonConfig) Reader added in v1.3.0

func (j JsonConfig) Reader() io.Reader

func (*JsonConfig) SaveToFile added in v1.3.0

func (j *JsonConfig) SaveToFile(filepath string) error

SaveToFile 保存json内容到filepath文件。 若 filepath 为空,则保存到默认 filepath

func (*JsonConfig) SetContent added in v1.3.0

func (j *JsonConfig) SetContent(v any) error

func (JsonConfig) String added in v1.3.0

func (j JsonConfig) String() string

type ProxyNode

type ProxyNode struct {
	Index, LocalPort int
	// cmd               *exec.Cmd
	Id              string
	RemoteAddr      string `json:"remote_addr"`
	Title, Protocol string
	TestUrl         string
	Speed           time.Duration
	TestAt          time.Time
	// contains filtered or unexported fields
}

func NewProxyNodeByV2ray

func NewProxyNodeByV2ray(vnd V2rayNode) *ProxyNode

func (*ProxyNode) AddToPool added in v1.1.1

func (p *ProxyNode) AddToPool(c *V2rayApiClient) error

func (*ProxyNode) GetId

func (p *ProxyNode) GetId() string

func (ProxyNode) IsOk

func (p ProxyNode) IsOk() bool

IsOk 查看测速是否超过有效期。默认24小时

func (ProxyNode) IsRunning

func (p ProxyNode) IsRunning() bool

func (*ProxyNode) Remove added in v1.1.1

func (p *ProxyNode) Remove(c *V2rayApiClient, tag string) error

func (*ProxyNode) SetV2ray

func (p *ProxyNode) SetV2ray(n V2rayNode) *ProxyNode

type ProxyNodes

type ProxyNodes []ProxyNode

func GetRunningNodes

func GetRunningNodes() ProxyNodes

func (ProxyNodes) Len

func (s ProxyNodes) Len() int

func (ProxyNodes) Less

func (s ProxyNodes) Less(i, j int) bool

func (*ProxyNodes) SortBySpeed

func (s *ProxyNodes) SortBySpeed()

func (ProxyNodes) Swap

func (s ProxyNodes) Swap(i, j int)

type ProxyPool

type ProxyPool struct {
	IsLock bool
	// contains filtered or unexported fields
}

func GetProxyPool

func GetProxyPool() *ProxyPool

func NewProxyPool

func NewProxyPool() *ProxyPool

func (*ProxyPool) ActiveNode

func (p *ProxyPool) ActiveNode(n ProxyNode, globalProxy bool) error

ActiveNode 激活一个节点作为系统代理。会新建一个v2ray线程来监听系统代理的入站端口。 globalProxy: windows可自动设置系统代理。true使用代理池节点的入站端口。false使用新v2ray线程的系统代理入站端口。

func (*ProxyPool) AddNode

func (p *ProxyPool) AddNode(n ProxyNode)

func (*ProxyPool) AddSpeedNode

func (p *ProxyPool) AddSpeedNode(key string, n ProxyNode)

func (*ProxyPool) AddV2rayServer added in v1.3.0

func (p *ProxyPool) AddV2rayServer(vs *V2rayServer) error

func (ProxyPool) CheckLocalPort added in v1.3.0

func (p ProxyPool) CheckLocalPort(checkPorts []int) error

func (ProxyPool) CheckV2rayConfig added in v1.3.0

func (p ProxyPool) CheckV2rayConfig(jconf JsonConfig) error

CheckV2rayConfig 检查配置项。判断入站端口号是否被占用。

func (*ProxyPool) DeleteV2rayServer added in v1.3.0

func (p *ProxyPool) DeleteV2rayServer(pid int) error

func (ProxyPool) GetActiveNode added in v1.2.0

func (p ProxyPool) GetActiveNode() ProxyNode

func (ProxyPool) GetLastSpeedNode added in v1.3.0

func (p ProxyPool) GetLastSpeedNode(nd ProxyNode, d string) ProxyNode

GetLastSpeedNode 查看当前节点是否存在测速信息

func (ProxyPool) GetLocalAddr

func (p ProxyPool) GetLocalAddr(n ProxyNode) string

func (ProxyPool) GetLocalPortList added in v1.3.0

func (p ProxyPool) GetLocalPortList() (dl []int, err error)

func (ProxyPool) GetLocalPortRange added in v1.3.0

func (p ProxyPool) GetLocalPortRange() string

func (*ProxyPool) GetNodes

func (p *ProxyPool) GetNodes(domain string) ProxyNodes

func (ProxyPool) GetTestedDomainList added in v1.3.0

func (p ProxyPool) GetTestedDomainList() []string

func (ProxyPool) GetV2rayServerList added in v1.3.0

func (p ProxyPool) GetV2rayServerList() []*V2rayServer

func (*ProxyPool) InitSubscribeData

func (p *ProxyPool) InitSubscribeData() *ProxyPool

func (*ProxyPool) KillAllNodes

func (p *ProxyPool) KillAllNodes() (total, runport, kill, fail int)

func (*ProxyPool) RemoveNode

func (p *ProxyPool) RemoveNode(n ProxyNode)

func (*ProxyPool) SetLocalAddr

func (p *ProxyPool) SetLocalAddr(n *ProxyNode, port int) string

func (*ProxyPool) SetLocalPortStart

func (p *ProxyPool) SetLocalPortStart(port int) *ProxyPool

func (*ProxyPool) SetSubscribeRawData

func (p *ProxyPool) SetSubscribeRawData(d string) *ProxyPool

func (*ProxyPool) SetSubscribeUrl

func (p *ProxyPool) SetSubscribeUrl(d string) *ProxyPool

func (*ProxyPool) SetTestMaxDuration

func (p *ProxyPool) SetTestMaxDuration(d time.Duration) *ProxyPool

func (*ProxyPool) SetTestUrl

func (p *ProxyPool) SetTestUrl(turl string) *ProxyPool

func (*ProxyPool) SetV2rayPath

func (p *ProxyPool) SetV2rayPath(path string) *ProxyPool

func (*ProxyPool) StartAll

func (p *ProxyPool) StartAll() error

StartAll 启动所有已停止的节点。

func (*ProxyPool) StartV2rayPool added in v1.3.0

func (p *ProxyPool) StartV2rayPool()

func (*ProxyPool) StopAll

func (p *ProxyPool) StopAll() error

func (*ProxyPool) TestAll

func (p *ProxyPool) TestAll()

func (*ProxyPool) TestAllForce

func (p *ProxyPool) TestAllForce()

func (*ProxyPool) UnActiveNode added in v1.2.0

func (p *ProxyPool) UnActiveNode(n ProxyNode) error

func (*ProxyPool) UpdateAfterStopAll

func (p *ProxyPool) UpdateAfterStopAll()

func (*ProxyPool) UpdateNode

func (p *ProxyPool) UpdateNode(n ProxyNode) error

func (*ProxyPool) UpdateSubscribe

func (p *ProxyPool) UpdateSubscribe() (total, add int)

type ProxyPoolServer

type ProxyPoolServer struct {
	g.UnimplementedProxyPoolServiceServer
}

func (ProxyPoolServer) ActiveProxyNode

func (s ProxyPoolServer) ActiveProxyNode(ctx context.Context, req *g.ProxyNode) (result *g.OptResult, err error)

func (ProxyPoolServer) GetProxyNodes

func (s ProxyPoolServer) GetProxyNodes(ctx context.Context, req *g.ProxyNode) (*g.ProxyNodes, error)

func (ProxyPoolServer) GetProxyNodesByDomain

func (s ProxyPoolServer) GetProxyNodesByDomain(ctx context.Context, req *g.OptRequestDomain) (*g.ProxyNodes, error)

func (ProxyPoolServer) KillAllNodes

func (s ProxyPoolServer) KillAllNodes(ctx context.Context, req *g.OptRequest) (result *g.KillNodesResult, err error)

func (ProxyPoolServer) SetTestUrl

func (s ProxyPoolServer) SetTestUrl(ctx context.Context, req *g.OptRequestUrl) (result *g.OptResult, err error)

func (ProxyPoolServer) StartProxyPoolAll

func (s ProxyPoolServer) StartProxyPoolAll(ctx context.Context, req *g.OptRequest) (result *g.OptResult, err error)

func (ProxyPoolServer) StopProxyPoolAll

func (s ProxyPoolServer) StopProxyPoolAll(ctx context.Context, req *g.OptRequest) (result *g.OptResult, err error)

func (ProxyPoolServer) TestProxyPoolAll

func (s ProxyPoolServer) TestProxyPoolAll(ctx context.Context, req *g.OptRequest) (result *g.OptResult, err error)

func (ProxyPoolServer) TestProxyPoolAllForce

func (s ProxyPoolServer) TestProxyPoolAllForce(ctx context.Context, req *g.OptRequest) (result *g.OptResult, err error)

func (ProxyPoolServer) UpdateProxySubscribe

func (s ProxyPoolServer) UpdateProxySubscribe(ctx context.Context, req *g.OptRequest) (result *g.UpdateSubscribeResult, err error)

type V2rayApiClient added in v1.1.1

type V2rayApiClient struct {
	// contains filtered or unexported fields
}

func NewV2rayApiClientV5 added in v1.1.1

func NewV2rayApiClientV5(addr string) *V2rayApiClient

func (V2rayApiClient) AddInbound added in v1.1.1

func (a V2rayApiClient) AddInbound(inport net.Port, intag, protocol string) error

AddInbound 添加入站规则 protocol http|socks

func (V2rayApiClient) AddOutboundByV2rayNode added in v1.1.1

func (a V2rayApiClient) AddOutboundByV2rayNode(nd V2rayNode, outag string) error

func (*V2rayApiClient) Close added in v1.1.1

func (a *V2rayApiClient) Close()

func (*V2rayApiClient) Dial added in v1.1.1

func (a *V2rayApiClient) Dial() error

func (V2rayApiClient) RemoveInbound added in v1.1.1

func (a V2rayApiClient) RemoveInbound(intag string) error

func (V2rayApiClient) RemoveOutbound added in v1.1.1

func (a V2rayApiClient) RemoveOutbound(outag string) error

type V2rayConfigV4

type V2rayConfigV4 struct {
	Log json.RawMessage `json:"log"`
	Api json.RawMessage `json:"api"`
	// Dns       json.RawMessage `json:"dns"`
	Routing   json.RawMessage `json:"routing"`
	Inbounds  []V2rayInbound  `json:"inbounds"`
	Outbounds []V2rayOutbound `json:"outbounds"`
}

type V2rayConfigV5

type V2rayConfigV5 struct {
	Log        json.RawMessage            `json:"log"`
	Dns        json.RawMessage            `json:"dns"`
	Router     json.RawMessage            `json:"router"`
	Inbounds   []V2rayInbound             `json:"inbounds"`
	Outbounds  []V2rayOutbound            `json:"outbounds"`
	Services   map[string]json.RawMessage `json:"services"`
	Extensions []json.RawMessage          `json:"extension"`
}

type V2rayInbound

type V2rayInbound struct {
	Protocol string
	Port     int
	Listen   string          // 默认值为 "0.0.0.0"
	Tag      string          // 此入站连接的标识,用于在其它的配置中定位此连接。当其不为空时,其值必须在所有 tag 中唯一。
	Settings json.RawMessage `json:"settings"` // {"auth":"noauth","udp":true,"ip":"%s"}
}

v4 {"port":%d,"listen":"%s","protocol":"http","settings":{"auth":"noauth","udp":true,"ip":"%s"}}

func NewV2rayInboundV4 added in v1.4.1

func NewV2rayInboundV4(proto string, inPort int) V2rayInbound

type V2rayNode

type V2rayNode struct {
	Protocol, Add, Host, Id, Net, Path, Ps, Tls, Type string
	V, Aid, Port                                      json.Number
}

"protocol":"vmess"

func ParseV2rayNodes

func ParseV2rayNodes(data string) []V2rayNode

ParseNodes 解析节点 Add, Ps ... {"add":"jp6.xxx.top","host":"","id":"0999AE93-1330-4A75-DBC1-0DD545F7DD60","net":"ws","path":"","port":"41444","ps":"xxx-v2-JP-Tokyo6(1)","tls":"","v":2,"aid":0,"type":"none"} {"add":"hk6.xxx.top","host":"","id":"93EA57CE-EA21-7240-EE7F-317F4A6A8B65","net":"ws","path":"","port":"444","ps":"xxx-v2-HK-HongKong6","tls":"tls","v":2,"aid":0, "type":"none"} vless://26DL68CE-DL93-8342-LQ8F-317F4A6E7J76@45.43.31.159:443?encryption=none&security=reality&sni=azure.microsoft.com&fp=safari&pbk=c7qU9-_0WflwIKUiZFxSss_xw-2AP3jB1ENxKLI0OTw&type=tcp&headerType=none#u9un-US-Xr1

type V2rayOutbound

type V2rayOutbound struct {
	Protocol    string          `json:"protocol"`
	SendThrough *string         `json:"sendThrough"` // 用于发送数据的 IP 地址,当主机有多个 IP 地址时有效,默认值为 "0.0.0.0"。
	Tag         string          `json:"tag"`
	Settings    json.RawMessage `json:"settings"` // 视协议不同而不同。详见每个协议中的 OutboundConfigurationObject
	// "streamSettings":{"network":"%s","tlsSettings":{"disableSystemRoot":false},"wsSettings":{"path":""},"xtlsSettings":{"disableSystemRoot":false}}
	StreamSetting json.RawMessage `json:"streamSettings"`
	ProxySettings json.RawMessage `json:"proxySettings"`
	Mux           json.RawMessage `json:"mux"`
}

type V2rayRouteRule

type V2rayRouteRule struct {
	DomainMatcher string   `json:"domainMatcher"`
	Type          string   `json:"type"`
	Domains       []string `json:"domains"`
	Ip            []string `json:"ip"`
	InboundTag    []string `json:"inboundTag"`
	OutboundTag   string   `json:"outboundTag"` //direct

}

V2rayRouteRule https://www.v2fly.org/config/routing.html#ruleobject

type V2rayServer

type V2rayServer struct {
	// contains filtered or unexported fields
}

func NewV2ray

func NewV2ray(v2rayPath string) *V2rayServer

func (V2rayServer) GetExeCmd added in v1.3.0

func (v V2rayServer) GetExeCmd() *exec.Cmd

func (V2rayServer) GetJsonConfig added in v1.3.0

func (v V2rayServer) GetJsonConfig() JsonConfig

func (V2rayServer) GetLocalPort added in v1.3.0

func (v V2rayServer) GetLocalPort() int

func (V2rayServer) GetV2rayConfigV4 added in v1.3.0

func (v V2rayServer) GetV2rayConfigV4() V2rayConfigV4

func (*V2rayServer) SetNode

func (v *V2rayServer) SetNode(n V2rayNode) *V2rayServer

func (*V2rayServer) SetPort

func (v *V2rayServer) SetPort(port int) *V2rayServer

func (*V2rayServer) Start

func (v *V2rayServer) Start(configFile string) error

Start 启动v2ray进程。非代理池模式,会读取 routing.rules.json 文件。 routing.rules.json 的值会覆盖 v2ray.config.json 对应配置项的值

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL