mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 20:50:09 +00:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e29c19f0e | ||
|
|
a1c40bb1c8 | ||
|
|
a0de94efff | ||
|
|
29928a1135 | ||
|
|
ab1ca837de | ||
|
|
1f61446fa9 | ||
|
|
c0325227db | ||
|
|
ba3036a7ac | ||
|
|
f99e2b4489 | ||
|
|
0af952be10 | ||
|
|
ad5971f164 | ||
|
|
f7d5d891c3 | ||
|
|
6936a76724 | ||
|
|
7184e49650 | ||
|
|
ea0b7d8f40 | ||
|
|
12fbcb1460 | ||
|
|
c6d48e1edf | ||
|
|
8d7168c6a4 | ||
|
|
173c48a76f | ||
|
|
130e94cf45 | ||
|
|
89ddfff060 | ||
|
|
07d49293d8 | ||
|
|
9e8f87740e | ||
|
|
29a99985c8 | ||
|
|
248ff3764f | ||
|
|
3dfeba7e68 | ||
|
|
a85352c402 |
22
.github/ISSUE_TEMPLATE/bug-report.md
vendored
22
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@@ -1,27 +1,25 @@
|
|||||||
---
|
---
|
||||||
name: "Bug 反馈"
|
name: "Bug 反馈"
|
||||||
about: 创建一个报告以帮助我们修复并改进XrayR
|
about: 创建一个报告以帮助我们修复并改进V2bX
|
||||||
title: ''
|
title: ''
|
||||||
labels: awaiting reply, bug
|
labels:
|
||||||
assignees: ''
|
assignees: ''
|
||||||
---
|
---
|
||||||
|
|
||||||
**描述该错误**
|
**描述该错误**
|
||||||
简单地描述一下这个bug是什么
|
简单地描述一下这个bug是什么
|
||||||
|
|
||||||
**复现**
|
|
||||||
复现该bug的步骤
|
|
||||||
|
|
||||||
**环境和版本**
|
|
||||||
- 系统 [例如:Debian 11]
|
**复现**
|
||||||
- 架构 [例如:AMD64]
|
请自行复现,并贴出详细步骤操作过程
|
||||||
- 面板 [例如:V2board]
|
|
||||||
- 协议 [例如:vmess]
|
|
||||||
- 版本 [例如:0.8.2.2]
|
|
||||||
- 部署方式 [例如:一键脚本]
|
|
||||||
|
|
||||||
**日志和错误**
|
**日志和错误**
|
||||||
请使用`xrayr log`查看并添加日志,以帮助解释你的问题
|
请使用`v2bx log`查看并添加日志,没有日志的issue不会得到答复并且会被直接关闭
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
**额外的内容**
|
**额外的内容**
|
||||||
在这里添加关于问题的任何其他内容
|
在这里添加关于问题的任何其他内容
|
||||||
19
.github/ISSUE_TEMPLATE/feature-request.md
vendored
19
.github/ISSUE_TEMPLATE/feature-request.md
vendored
@@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
name: "功能建议"
|
|
||||||
about: 给XrayR提出建议,让我们做得更好
|
|
||||||
title: ''
|
|
||||||
labels: awaiting reply, feature-request
|
|
||||||
assignees: ''
|
|
||||||
---
|
|
||||||
|
|
||||||
**描述您想要的功能**
|
|
||||||
|
|
||||||
清晰简洁的功能描述。
|
|
||||||
|
|
||||||
**描述您考虑过的替代方案**
|
|
||||||
|
|
||||||
是否有任何替代方案可以解决这个问题?
|
|
||||||
|
|
||||||
**附加上下文**
|
|
||||||
|
|
||||||
在此处添加有关功能请求的任何其他上下文或截图。
|
|
||||||
12
.github/workflows/Publish Docker image.yml
vendored
12
.github/workflows/Publish Docker image.yml
vendored
@@ -1,16 +1,8 @@
|
|||||||
name: Publish Docker image
|
name: Publish Docker image
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
release:
|
||||||
branches:
|
types: [published]
|
||||||
- dev_new
|
|
||||||
paths:
|
|
||||||
- "**/*.go"
|
|
||||||
- "go.mod"
|
|
||||||
- "go.sum"
|
|
||||||
- ".github/workflows/*.yml"
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- 'dev_new'
|
- 'dev_new'
|
||||||
|
|||||||
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -98,7 +98,7 @@ jobs:
|
|||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout codebase
|
- name: Checkout codebase
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Show workflow information
|
- name: Show workflow information
|
||||||
id: get_filename
|
id: get_filename
|
||||||
run: |
|
run: |
|
||||||
@@ -107,9 +107,9 @@ jobs:
|
|||||||
echo "ASSET_NAME=$_NAME" >> $GITHUB_OUTPUT
|
echo "ASSET_NAME=$_NAME" >> $GITHUB_OUTPUT
|
||||||
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
|
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.22.0'
|
go-version: '1.23.2'
|
||||||
|
|
||||||
- name: Get project dependencies
|
- name: Get project dependencies
|
||||||
run: go mod download
|
run: go mod download
|
||||||
@@ -167,7 +167,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mv build_assets V2bX-$ASSET_NAME
|
mv build_assets V2bX-$ASSET_NAME
|
||||||
- name: Upload files to Artifacts
|
- name: Upload files to Artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: V2bX-${{ steps.get_filename.outputs.ASSET_NAME }}
|
name: V2bX-${{ steps.get_filename.outputs.ASSET_NAME }}
|
||||||
path: |
|
path: |
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Build go
|
# Build go
|
||||||
FROM golang:1.22.0-alpine AS builder
|
FROM golang:1.23.2-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV CGO_ENABLED=0
|
ENV CGO_ENABLED=0
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -1,16 +1,17 @@
|
|||||||
# V2bX
|
# V2bX
|
||||||
|
|
||||||
[](https://t.me/YuzukiProjects)
|
[](https://t.me/unofficialV2board)
|
||||||
|
[](https://t.me/YuzukiProjects)
|
||||||
|
|
||||||
A V2board node server based on multi core, modified from XrayR.
|
A V2board node server based on multi core, modified from XrayR.
|
||||||
一个基于多种内核的V2board节点服务端,修改自XrayR,支持V2ay,Trojan,Shadowsocks协议。
|
一个基于多种内核的V2board节点服务端,修改自XrayR,支持V2ay,Trojan,Shadowsocks协议。
|
||||||
|
|
||||||
**注意: 本项目需要V2board版本 >= 1.7.0**
|
**注意: 本项目需要搭配[修改版V2board](https://github.com/wyx2685/v2board)**
|
||||||
|
|
||||||
## 特点
|
## 特点
|
||||||
|
|
||||||
* 永久开源且免费。
|
* 永久开源且免费。
|
||||||
* 支持Vmess/Vless, Trojan, Shadowsocks, Hysteria多种协议。
|
* 支持Vmess/Vless, Trojan, Shadowsocks, Hysteria1/2多种协议。
|
||||||
* 支持Vless和XTLS等新特性。
|
* 支持Vless和XTLS等新特性。
|
||||||
* 支持单实例对接多节点,无需重复启动。
|
* 支持单实例对接多节点,无需重复启动。
|
||||||
* 支持限制在线IP。
|
* 支持限制在线IP。
|
||||||
@@ -23,7 +24,7 @@ A V2board node server based on multi core, modified from XrayR.
|
|||||||
|
|
||||||
## 功能介绍
|
## 功能介绍
|
||||||
|
|
||||||
| 功能 | v2ray | trojan | shadowsocks | hysteria |
|
| 功能 | v2ray | trojan | shadowsocks | hysteria1/2 |
|
||||||
|-----------|-------|--------|-------------|----------|
|
|-----------|-------|--------|-------------|----------|
|
||||||
| 自动申请tls证书 | √ | √ | √ | √ |
|
| 自动申请tls证书 | √ | √ | √ | √ |
|
||||||
| 自动续签tls证书 | √ | √ | √ | √ |
|
| 自动续签tls证书 | √ | √ | √ | √ |
|
||||||
@@ -32,7 +33,7 @@ A V2board node server based on multi core, modified from XrayR.
|
|||||||
| 自定义DNS | √ | √ | √ | √ |
|
| 自定义DNS | √ | √ | √ | √ |
|
||||||
| 在线IP数限制 | √ | √ | √ | √ |
|
| 在线IP数限制 | √ | √ | √ | √ |
|
||||||
| 连接数限制 | √ | √ | √ | √ |
|
| 连接数限制 | √ | √ | √ | √ |
|
||||||
| 跨节点IP数限制 | | | | |
|
| 跨节点IP数限制 |√ |√ |√ |√ |
|
||||||
| 按照用户限速 | √ | √ | √ | √ |
|
| 按照用户限速 | √ | √ | √ | √ |
|
||||||
| 动态限速(未测试) | √ | √ | √ | √ |
|
| 动态限速(未测试) | √ | √ | √ | √ |
|
||||||
|
|
||||||
@@ -56,8 +57,8 @@ wget -N https://raw.githubusercontent.com/wyx2685/V2bX-script/master/install.sh
|
|||||||
|
|
||||||
## 构建
|
## 构建
|
||||||
``` bash
|
``` bash
|
||||||
# 通过-tags选项指定要编译的内核, 可选 xray, sing
|
# 通过-tags选项指定要编译的内核, 可选 xray, sing, hysteria2
|
||||||
go build -v -o ./V2bX -tags "sing hysteria2 with_reality_server with_quic with_grpc with_utls with_wireguard with_acme" -trimpath -ldflags "-s -w -buildid="
|
go build -v -o ./V2bX -tags "xray sing hysteria2 with_reality_server with_quic with_grpc with_utls with_wireguard with_acme" -trimpath -ldflags "-s -w -buildid="
|
||||||
```
|
```
|
||||||
|
|
||||||
## 配置文件及详细使用教程
|
## 配置文件及详细使用教程
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ type Client struct {
|
|||||||
nodeEtag string
|
nodeEtag string
|
||||||
userEtag string
|
userEtag string
|
||||||
responseBodyHash string
|
responseBodyHash string
|
||||||
LastReportOnline map[int]int
|
UserList *UserListBody
|
||||||
|
AliveMap *AliveMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(c *conf.ApiConfig) (*Client, error) {
|
func New(c *conf.ApiConfig) (*Client, error) {
|
||||||
@@ -71,5 +72,7 @@ func New(c *conf.ApiConfig) (*Client, error) {
|
|||||||
APIHost: c.APIHost,
|
APIHost: c.APIHost,
|
||||||
NodeType: c.NodeType,
|
NodeType: c.NodeType,
|
||||||
NodeId: c.NodeID,
|
NodeId: c.NodeID,
|
||||||
|
UserList: &UserListBody{},
|
||||||
|
AliveMap: &AliveMap{},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ type UserInfo struct {
|
|||||||
Uuid string `json:"uuid"`
|
Uuid string `json:"uuid"`
|
||||||
SpeedLimit int `json:"speed_limit"`
|
SpeedLimit int `json:"speed_limit"`
|
||||||
DeviceLimit int `json:"device_limit"`
|
DeviceLimit int `json:"device_limit"`
|
||||||
AliveIp int `json:"alive_ip"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserListBody struct {
|
type UserListBody struct {
|
||||||
@@ -24,62 +23,59 @@ type UserListBody struct {
|
|||||||
Users []UserInfo `json:"users"`
|
Users []UserInfo `json:"users"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserList will pull user form sspanel
|
type AliveMap struct {
|
||||||
func (c *Client) GetUserList() (UserList []UserInfo, err error) {
|
Alive map[int]int `json:"alive"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserList will pull user from v2board
|
||||||
|
func (c *Client) GetUserList() ([]UserInfo, error) {
|
||||||
const path = "/api/v1/server/UniProxy/user"
|
const path = "/api/v1/server/UniProxy/user"
|
||||||
r, err := c.client.R().
|
r, err := c.client.R().
|
||||||
SetHeader("If-None-Match", c.userEtag).
|
SetHeader("If-None-Match", c.userEtag).
|
||||||
ForceContentType("application/json").
|
ForceContentType("application/json").
|
||||||
Get(path)
|
Get(path)
|
||||||
|
if r == nil || r.RawResponse == nil {
|
||||||
|
return nil, fmt.Errorf("received nil response or raw response")
|
||||||
|
}
|
||||||
|
defer r.RawResponse.Body.Close()
|
||||||
|
|
||||||
|
if r.StatusCode() == 304 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
if err = c.checkResponse(r, path, err); err != nil {
|
if err = c.checkResponse(r, path, err); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
userlist := &UserListBody{}
|
||||||
if r != nil {
|
if err := json.Unmarshal(r.Body(), userlist); err != nil {
|
||||||
defer func() {
|
return nil, fmt.Errorf("unmarshal user list error: %w", err)
|
||||||
if r.RawBody() != nil {
|
|
||||||
r.RawBody().Close()
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if r.StatusCode() == 304 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("received nil response")
|
|
||||||
}
|
|
||||||
var userList *UserListBody
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("read body error: %s", err)
|
|
||||||
}
|
|
||||||
if err := json.Unmarshal(r.Body(), &userList); err != nil {
|
|
||||||
return nil, fmt.Errorf("unmarshal userlist error: %s", err)
|
|
||||||
}
|
}
|
||||||
c.userEtag = r.Header().Get("ETag")
|
c.userEtag = r.Header().Get("ETag")
|
||||||
|
return userlist.Users, nil
|
||||||
|
}
|
||||||
|
|
||||||
var userinfos []UserInfo
|
// GetUserAlive will fetch the alive_ip count for users
|
||||||
var deviceLimit, localDeviceLimit int = 0, 0
|
func (c *Client) GetUserAlive() (map[int]int, error) {
|
||||||
for _, user := range userList.Users {
|
const path = "/api/v1/server/UniProxy/alivelist"
|
||||||
// If there is still device available, add the user
|
r, err := c.client.R().
|
||||||
if user.DeviceLimit > 0 && user.AliveIp > 0 {
|
ForceContentType("application/json").
|
||||||
lastOnline := 0
|
Get(path)
|
||||||
if v, ok := c.LastReportOnline[user.Id]; ok {
|
if r == nil || r.RawResponse == nil {
|
||||||
lastOnline = v
|
return nil, fmt.Errorf("received nil response or raw response")
|
||||||
}
|
}
|
||||||
// If there are any available device.
|
defer r.RawResponse.Body.Close()
|
||||||
localDeviceLimit = user.DeviceLimit - user.AliveIp + lastOnline
|
|
||||||
if localDeviceLimit > 0 {
|
c.AliveMap = &AliveMap{}
|
||||||
deviceLimit = localDeviceLimit
|
if err != nil || r.StatusCode() >= 399 {
|
||||||
} else if lastOnline > 0 {
|
c.AliveMap.Alive = make(map[int]int)
|
||||||
deviceLimit = lastOnline
|
return c.AliveMap.Alive, nil
|
||||||
} else {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
user.DeviceLimit = deviceLimit
|
|
||||||
userinfos = append(userinfos, user)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return userinfos, nil
|
if err := json.Unmarshal(r.Body(), c.AliveMap); err != nil {
|
||||||
|
return nil, fmt.Errorf("unmarshal user alive list error: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.AliveMap.Alive, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserTraffic struct {
|
type UserTraffic struct {
|
||||||
@@ -106,8 +102,7 @@ func (c *Client) ReportUserTraffic(userTraffic []UserTraffic) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) ReportNodeOnlineUsers(data *map[int][]string, reportOnline *map[int]int) error {
|
func (c *Client) ReportNodeOnlineUsers(data *map[int][]string) error {
|
||||||
c.LastReportOnline = *reportOnline
|
|
||||||
const path = "/api/v1/server/UniProxy/alive"
|
const path = "/api/v1/server/UniProxy/alive"
|
||||||
r, err := c.client.R().
|
r, err := c.client.R().
|
||||||
SetBody(data).
|
SetBody(data).
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type TrafficCounter struct {
|
type TrafficCounter struct {
|
||||||
counters map[string]*TrafficStorage
|
counters sync.Map
|
||||||
lock sync.RWMutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type TrafficStorage struct {
|
type TrafficStorage struct {
|
||||||
@@ -16,60 +15,52 @@ type TrafficStorage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewTrafficCounter() *TrafficCounter {
|
func NewTrafficCounter() *TrafficCounter {
|
||||||
return &TrafficCounter{
|
return &TrafficCounter{}
|
||||||
counters: map[string]*TrafficStorage{},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TrafficCounter) GetCounter(id string) *TrafficStorage {
|
func (c *TrafficCounter) GetCounter(id string) *TrafficStorage {
|
||||||
c.lock.RLock()
|
if cts, ok := c.counters.Load(id); ok {
|
||||||
cts, ok := c.counters[id]
|
return cts.(*TrafficStorage)
|
||||||
c.lock.RUnlock()
|
|
||||||
if !ok {
|
|
||||||
cts = &TrafficStorage{}
|
|
||||||
c.counters[id] = cts
|
|
||||||
}
|
}
|
||||||
return cts
|
newStorage := &TrafficStorage{}
|
||||||
|
if cts, loaded := c.counters.LoadOrStore(id, newStorage); loaded {
|
||||||
|
return cts.(*TrafficStorage)
|
||||||
|
}
|
||||||
|
return newStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TrafficCounter) GetUpCount(id string) int64 {
|
func (c *TrafficCounter) GetUpCount(id string) int64 {
|
||||||
c.lock.RLock()
|
if cts, ok := c.counters.Load(id); ok {
|
||||||
cts, ok := c.counters[id]
|
return cts.(*TrafficStorage).UpCounter.Load()
|
||||||
c.lock.RUnlock()
|
|
||||||
if ok {
|
|
||||||
return cts.UpCounter.Load()
|
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TrafficCounter) GetDownCount(id string) int64 {
|
func (c *TrafficCounter) GetDownCount(id string) int64 {
|
||||||
c.lock.RLock()
|
if cts, ok := c.counters.Load(id); ok {
|
||||||
cts, ok := c.counters[id]
|
return cts.(*TrafficStorage).DownCounter.Load()
|
||||||
c.lock.RUnlock()
|
|
||||||
if ok {
|
|
||||||
return cts.DownCounter.Load()
|
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TrafficCounter) Len() int {
|
func (c *TrafficCounter) Len() int {
|
||||||
c.lock.RLock()
|
length := 0
|
||||||
defer c.lock.RUnlock()
|
c.counters.Range(func(_, _ interface{}) bool {
|
||||||
return len(c.counters)
|
length++
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return length
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TrafficCounter) Reset(id string) {
|
func (c *TrafficCounter) Reset(id string) {
|
||||||
c.lock.RLock()
|
if cts, ok := c.counters.Load(id); ok {
|
||||||
cts := c.GetCounter(id)
|
cts.(*TrafficStorage).UpCounter.Store(0)
|
||||||
c.lock.RUnlock()
|
cts.(*TrafficStorage).DownCounter.Store(0)
|
||||||
cts.UpCounter.Store(0)
|
}
|
||||||
cts.DownCounter.Store(0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TrafficCounter) Delete(id string) {
|
func (c *TrafficCounter) Delete(id string) {
|
||||||
c.lock.Lock()
|
c.counters.Delete(id)
|
||||||
delete(c.counters, id)
|
|
||||||
c.lock.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TrafficCounter) Rx(id string, n int) {
|
func (c *TrafficCounter) Rx(id string, n int) {
|
||||||
@@ -81,11 +72,3 @@ func (c *TrafficCounter) Tx(id string, n int) {
|
|||||||
cts := c.GetCounter(id)
|
cts := c.GetCounter(id)
|
||||||
cts.UpCounter.Add(int64(n))
|
cts.UpCounter.Add(int64(n))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TrafficCounter) IncConn(auth string) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *TrafficCounter) DecConn(auth string) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/juju/ratelimit"
|
"github.com/juju/ratelimit"
|
||||||
"github.com/sagernet/sing/common/buf"
|
|
||||||
M "github.com/sagernet/sing/common/metadata"
|
|
||||||
"github.com/sagernet/sing/common/network"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewConnRateLimiter(c net.Conn, l *ratelimit.Bucket) *Conn {
|
func NewConnRateLimiter(c net.Conn, l *ratelimit.Bucket) *Conn {
|
||||||
@@ -31,6 +28,7 @@ func (c *Conn) Write(b []byte) (n int, err error) {
|
|||||||
return c.Conn.Write(b)
|
return c.Conn.Write(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
type PacketConnCounter struct {
|
type PacketConnCounter struct {
|
||||||
network.PacketConn
|
network.PacketConn
|
||||||
limiter *ratelimit.Bucket
|
limiter *ratelimit.Bucket
|
||||||
@@ -47,10 +45,11 @@ func (p *PacketConnCounter) ReadPacket(buff *buf.Buffer) (destination M.Socksadd
|
|||||||
pLen := buff.Len()
|
pLen := buff.Len()
|
||||||
destination, err = p.PacketConn.ReadPacket(buff)
|
destination, err = p.PacketConn.ReadPacket(buff)
|
||||||
p.limiter.Wait(int64(buff.Len() - pLen))
|
p.limiter.Wait(int64(buff.Len() - pLen))
|
||||||
return
|
return destination, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PacketConnCounter) WritePacket(buff *buf.Buffer, destination M.Socksaddr) (err error) {
|
func (p *PacketConnCounter) WritePacket(buff *buf.Buffer, destination M.Socksaddr) (err error) {
|
||||||
p.limiter.Wait(int64(buff.Len()))
|
p.limiter.Wait(int64(buff.Len()))
|
||||||
return p.PacketConn.WritePacket(buff, destination)
|
return p.PacketConn.WritePacket(buff, destination)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|||||||
18
conf/sing.go
18
conf/sing.go
@@ -33,13 +33,13 @@ func NewSingConfig() *SingConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SingOptions struct {
|
type SingOptions struct {
|
||||||
EnableProxyProtocol bool `json:"EnableProxyProtocol"`
|
|
||||||
TCPFastOpen bool `json:"EnableTFO"`
|
TCPFastOpen bool `json:"EnableTFO"`
|
||||||
SniffEnabled bool `json:"EnableSniff"`
|
SniffEnabled bool `json:"EnableSniff"`
|
||||||
|
SniffOverrideDestination bool `json:"SniffOverrideDestination"`
|
||||||
EnableDNS bool `json:"EnableDNS"`
|
EnableDNS bool `json:"EnableDNS"`
|
||||||
DomainStrategy option.DomainStrategy `json:"DomainStrategy"`
|
DomainStrategy option.DomainStrategy `json:"DomainStrategy"`
|
||||||
SniffOverrideDestination bool `json:"SniffOverrideDestination"`
|
|
||||||
FallBackConfigs *FallBackConfigForSing `json:"FallBackConfigs"`
|
FallBackConfigs *FallBackConfigForSing `json:"FallBackConfigs"`
|
||||||
|
Multiplex *MultiplexConfig `json:"MultiplexConfig"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SingNtpConfig struct {
|
type SingNtpConfig struct {
|
||||||
@@ -59,13 +59,25 @@ type FallBack struct {
|
|||||||
ServerPort string `json:"ServerPort"`
|
ServerPort string `json:"ServerPort"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MultiplexConfig struct {
|
||||||
|
Enabled bool `json:"Enable"`
|
||||||
|
Padding bool `json:"Padding"`
|
||||||
|
Brutal BrutalOptions `json:"Brutal"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BrutalOptions struct {
|
||||||
|
Enabled bool `json:"Enable"`
|
||||||
|
UpMbps int `json:"UpMbps"`
|
||||||
|
DownMbps int `json:"DownMbps"`
|
||||||
|
}
|
||||||
|
|
||||||
func NewSingOptions() *SingOptions {
|
func NewSingOptions() *SingOptions {
|
||||||
return &SingOptions{
|
return &SingOptions{
|
||||||
EnableDNS: false,
|
EnableDNS: false,
|
||||||
EnableProxyProtocol: false,
|
|
||||||
TCPFastOpen: false,
|
TCPFastOpen: false,
|
||||||
SniffEnabled: true,
|
SniffEnabled: true,
|
||||||
SniffOverrideDestination: true,
|
SniffOverrideDestination: true,
|
||||||
FallBackConfigs: &FallBackConfigForSing{},
|
FallBackConfigs: &FallBackConfigForSing{},
|
||||||
|
Multiplex: &MultiplexConfig{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,15 +284,23 @@ func (n *Hysteria2node) getMasqHandler(tlsconfig *server.TLSConfig, conn net.Pac
|
|||||||
}
|
}
|
||||||
u, err := url.Parse(c.Masquerade.Proxy.URL)
|
u, err := url.Parse(c.Masquerade.Proxy.URL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf(fmt.Sprintf("masquerade.proxy.url %s", err))
|
return nil, fmt.Errorf("masquerade.proxy.url %s", err)
|
||||||
}
|
}
|
||||||
handler = &httputil.ReverseProxy{
|
handler = &httputil.ReverseProxy{
|
||||||
Rewrite: func(r *httputil.ProxyRequest) {
|
Director: func(req *http.Request) {
|
||||||
r.SetURL(u)
|
req.URL.Scheme = u.Scheme
|
||||||
// SetURL rewrites the Host header,
|
req.URL.Host = u.Host
|
||||||
// but we don't want that if rewriteHost is false
|
|
||||||
|
if clientIP, _, err := net.SplitHostPort(req.RemoteAddr); err == nil {
|
||||||
|
xff := req.Header.Get("X-Forwarded-For")
|
||||||
|
if xff != "" {
|
||||||
|
clientIP = xff + ", " + clientIP
|
||||||
|
}
|
||||||
|
req.Header.Set("X-Forwarded-For", clientIP)
|
||||||
|
}
|
||||||
|
|
||||||
if !c.Masquerade.Proxy.RewriteHost {
|
if !c.Masquerade.Proxy.RewriteHost {
|
||||||
r.Out.Host = r.In.Host
|
req.Host = req.URL.Host
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ErrorHandler: func(w http.ResponseWriter, r *http.Request, err error) {
|
ErrorHandler: func(w http.ResponseWriter, r *http.Request, err error) {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func (l *serverLogger) Connect(addr net.Addr, uuid string, tx uint64) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
l.logger.Panic("Get limiter error", zap.String("tag", l.Tag), zap.Error(err))
|
l.logger.Panic("Get limiter error", zap.String("tag", l.Tag), zap.Error(err))
|
||||||
}
|
}
|
||||||
if _, r := limiterinfo.CheckLimit(format.UserTag(l.Tag, uuid), extractIPFromAddr(addr), addr.Network() == "tcp"); r {
|
if _, r := limiterinfo.CheckLimit(format.UserTag(l.Tag, uuid), extractIPFromAddr(addr), addr.Network() == "tcp", true); r {
|
||||||
if userLimit, ok := limiterinfo.UserLimitInfo.Load(format.UserTag(l.Tag, uuid)); ok {
|
if userLimit, ok := limiterinfo.UserLimitInfo.Load(format.UserTag(l.Tag, uuid)); ok {
|
||||||
userLimit.(*limiter.UserLimitInfo).OverLimit = true
|
userLimit.(*limiter.UserLimitInfo).OverLimit = true
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ func (l *serverLogger) TCPRequest(addr net.Addr, uuid, reqAddr string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
l.logger.Panic("Get limiter error", zap.String("tag", l.Tag), zap.Error(err))
|
l.logger.Panic("Get limiter error", zap.String("tag", l.Tag), zap.Error(err))
|
||||||
}
|
}
|
||||||
if _, r := limiterinfo.CheckLimit(format.UserTag(l.Tag, uuid), extractIPFromAddr(addr), addr.Network() == "tcp"); r {
|
if _, r := limiterinfo.CheckLimit(format.UserTag(l.Tag, uuid), extractIPFromAddr(addr), addr.Network() == "tcp", true); r {
|
||||||
if userLimit, ok := limiterinfo.UserLimitInfo.Load(format.UserTag(l.Tag, uuid)); ok {
|
if userLimit, ok := limiterinfo.UserLimitInfo.Load(format.UserTag(l.Tag, uuid)); ok {
|
||||||
userLimit.(*limiter.UserLimitInfo).OverLimit = true
|
userLimit.(*limiter.UserLimitInfo).OverLimit = true
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ func (l *serverLogger) UDPRequest(addr net.Addr, uuid string, sessionId uint32,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
l.logger.Panic("Get limiter error", zap.String("tag", l.Tag), zap.Error(err))
|
l.logger.Panic("Get limiter error", zap.String("tag", l.Tag), zap.Error(err))
|
||||||
}
|
}
|
||||||
if _, r := limiterinfo.CheckLimit(format.UserTag(l.Tag, uuid), extractIPFromAddr(addr), addr.Network() == "tcp"); r {
|
if _, r := limiterinfo.CheckLimit(format.UserTag(l.Tag, uuid), extractIPFromAddr(addr), addr.Network() == "tcp", true); r {
|
||||||
if userLimit, ok := limiterinfo.UserLimitInfo.Load(format.UserTag(l.Tag, uuid)); ok {
|
if userLimit, ok := limiterinfo.UserLimitInfo.Load(format.UserTag(l.Tag, uuid)); ok {
|
||||||
userLimit.(*limiter.UserLimitInfo).OverLimit = true
|
userLimit.(*limiter.UserLimitInfo).OverLimit = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ func (h *HookServer) RoutedConnection(_ context.Context, conn net.Conn, m adapte
|
|||||||
return conn, t
|
return conn, t
|
||||||
}
|
}
|
||||||
ip := m.Source.Addr.String()
|
ip := m.Source.Addr.String()
|
||||||
if b, r := l.CheckLimit(format.UserTag(m.Inbound, m.User), ip, true); r {
|
if b, r := l.CheckLimit(format.UserTag(m.Inbound, m.User), ip, true, true); r {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
log.Error("[", m.Inbound, "] ", "Limited ", m.User, " by ip or conn")
|
log.Error("[", m.Inbound, "] ", "Limited ", m.User, " by ip or conn")
|
||||||
return conn, t
|
return conn, t
|
||||||
@@ -162,12 +162,12 @@ func (h *HookServer) RoutedPacketConnection(_ context.Context, conn N.PacketConn
|
|||||||
return conn, t
|
return conn, t
|
||||||
}
|
}
|
||||||
ip := m.Source.Addr.String()
|
ip := m.Source.Addr.String()
|
||||||
if b, r := l.CheckLimit(format.UserTag(m.Inbound, m.User), ip, true); r {
|
if b, r := l.CheckLimit(format.UserTag(m.Inbound, m.User), ip, false, false); r {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
log.Error("[", m.Inbound, "] ", "Limited ", m.User, " by ip or conn")
|
log.Error("[", m.Inbound, "] ", "Limited ", m.User, " by ip or conn")
|
||||||
return conn, t
|
return conn, t
|
||||||
} else if b != nil {
|
} else if b != nil {
|
||||||
conn = rate.NewPacketConnCounter(conn, b)
|
//conn = rate.NewPacketConnCounter(conn, b)
|
||||||
}
|
}
|
||||||
if h.EnableConnClear {
|
if h.EnableConnClear {
|
||||||
var key int
|
var key int
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
|
|||||||
listen := option.ListenOptions{
|
listen := option.ListenOptions{
|
||||||
Listen: (*option.ListenAddress)(&addr),
|
Listen: (*option.ListenAddress)(&addr),
|
||||||
ListenPort: uint16(info.Common.ServerPort),
|
ListenPort: uint16(info.Common.ServerPort),
|
||||||
ProxyProtocol: c.SingOptions.EnableProxyProtocol,
|
|
||||||
TCPFastOpen: c.SingOptions.TCPFastOpen,
|
TCPFastOpen: c.SingOptions.TCPFastOpen,
|
||||||
InboundOptions: option.InboundOptions{
|
InboundOptions: option.InboundOptions{
|
||||||
SniffEnabled: c.SingOptions.SniffEnabled,
|
SniffEnabled: c.SingOptions.SniffEnabled,
|
||||||
@@ -69,6 +68,19 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
|
|||||||
DomainStrategy: domainStrategy,
|
DomainStrategy: domainStrategy,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
var multiplex *option.InboundMultiplexOptions
|
||||||
|
if c.SingOptions.Multiplex != nil {
|
||||||
|
multiplexOption := option.InboundMultiplexOptions{
|
||||||
|
Enabled: c.SingOptions.Multiplex.Enabled,
|
||||||
|
Padding: c.SingOptions.Multiplex.Padding,
|
||||||
|
Brutal: &option.BrutalOptions{
|
||||||
|
Enabled: c.SingOptions.Multiplex.Brutal.Enabled,
|
||||||
|
UpMbps: c.SingOptions.Multiplex.Brutal.UpMbps,
|
||||||
|
DownMbps: c.SingOptions.Multiplex.Brutal.DownMbps,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
multiplex = &multiplexOption
|
||||||
|
}
|
||||||
var tls option.InboundTLSOptions
|
var tls option.InboundTLSOptions
|
||||||
switch info.Security {
|
switch info.Security {
|
||||||
case panel.Tls:
|
case panel.Tls:
|
||||||
@@ -210,6 +222,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
|
|||||||
TLS: &tls,
|
TLS: &tls,
|
||||||
},
|
},
|
||||||
Transport: &t,
|
Transport: &t,
|
||||||
|
Multiplex: multiplex,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
in.Type = "vmess"
|
in.Type = "vmess"
|
||||||
@@ -219,6 +232,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
|
|||||||
TLS: &tls,
|
TLS: &tls,
|
||||||
},
|
},
|
||||||
Transport: &t,
|
Transport: &t,
|
||||||
|
Multiplex: multiplex,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "shadowsocks":
|
case "shadowsocks":
|
||||||
@@ -236,6 +250,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
|
|||||||
in.ShadowsocksOptions = option.ShadowsocksInboundOptions{
|
in.ShadowsocksOptions = option.ShadowsocksInboundOptions{
|
||||||
ListenOptions: listen,
|
ListenOptions: listen,
|
||||||
Method: n.Cipher,
|
Method: n.Cipher,
|
||||||
|
Multiplex: multiplex,
|
||||||
}
|
}
|
||||||
p := make([]byte, keyLength)
|
p := make([]byte, keyLength)
|
||||||
_, _ = rand.Read(p)
|
_, _ = rand.Read(p)
|
||||||
@@ -308,6 +323,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
|
|||||||
TLS: &tls,
|
TLS: &tls,
|
||||||
},
|
},
|
||||||
Transport: &t,
|
Transport: &t,
|
||||||
|
Multiplex: multiplex,
|
||||||
}
|
}
|
||||||
if c.SingOptions.FallBackConfigs != nil {
|
if c.SingOptions.FallBackConfigs != nil {
|
||||||
// fallback handling
|
// fallback handling
|
||||||
|
|||||||
@@ -177,7 +177,8 @@ func (d *DefaultDispatcher) getLink(ctx context.Context, network net.Network) (*
|
|||||||
// Speed Limit and Device Limit
|
// Speed Limit and Device Limit
|
||||||
w, reject := limit.CheckLimit(user.Email,
|
w, reject := limit.CheckLimit(user.Email,
|
||||||
sessionInbound.Source.Address.IP().String(),
|
sessionInbound.Source.Address.IP().String(),
|
||||||
network == net.Network_TCP)
|
network == net.Network_TCP,
|
||||||
|
sessionInbound.Source.Network == net.Network_TCP)
|
||||||
if reject {
|
if reject {
|
||||||
errors.LogInfo(ctx, "Limited ", user.Email, " by conn or ip")
|
errors.LogInfo(ctx, "Limited ", user.Email, " by conn or ip")
|
||||||
common.Close(outboundLink.Writer)
|
common.Close(outboundLink.Writer)
|
||||||
@@ -241,7 +242,7 @@ func (d *DefaultDispatcher) shouldOverride(ctx context.Context, result SniffResu
|
|||||||
protocolString = resComp.ProtocolForDomainResult()
|
protocolString = resComp.ProtocolForDomainResult()
|
||||||
}
|
}
|
||||||
for _, p := range request.OverrideDestinationForProtocol {
|
for _, p := range request.OverrideDestinationForProtocol {
|
||||||
if strings.HasPrefix(protocolString, p) || strings.HasPrefix(protocolString, p) {
|
if strings.HasPrefix(protocolString, p) || strings.HasPrefix(p, protocolString) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && protocolString != "bittorrent" && p == "fakedns" &&
|
if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && protocolString != "bittorrent" && p == "fakedns" &&
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ type Sniffer struct {
|
|||||||
func NewSniffer(ctx context.Context) *Sniffer {
|
func NewSniffer(ctx context.Context) *Sniffer {
|
||||||
ret := &Sniffer{
|
ret := &Sniffer{
|
||||||
sniffer: []protocolSnifferWithMetadata{
|
sniffer: []protocolSnifferWithMetadata{
|
||||||
{func(c context.Context, b []byte) (SniffResult, error) { return http.SniffHTTP(b) }, false, net.Network_TCP},
|
{func(c context.Context, b []byte) (SniffResult, error) { return http.SniffHTTP(b, ctx) }, false, net.Network_TCP},
|
||||||
{func(c context.Context, b []byte) (SniffResult, error) { return tls.SniffTLS(b) }, false, net.Network_TCP},
|
{func(c context.Context, b []byte) (SniffResult, error) { return tls.SniffTLS(b) }, false, net.Network_TCP},
|
||||||
{func(c context.Context, b []byte) (SniffResult, error) { return bittorrent.SniffBittorrent(b) }, false, net.Network_TCP},
|
{func(c context.Context, b []byte) (SniffResult, error) { return bittorrent.SniffBittorrent(b) }, false, net.Network_TCP},
|
||||||
{func(c context.Context, b []byte) (SniffResult, error) { return quic.SniffQUIC(b) }, false, net.Network_UDP},
|
{func(c context.Context, b []byte) (SniffResult, error) { return quic.SniffQUIC(b) }, false, net.Network_UDP},
|
||||||
|
|||||||
@@ -213,11 +213,6 @@ func buildV2ray(config *conf.Options, nodeInfo *panel.NodeInfo, inbound *coreCon
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unmarshal grpc settings error: %s", err)
|
return fmt.Errorf("unmarshal grpc settings error: %s", err)
|
||||||
}
|
}
|
||||||
case "quic":
|
|
||||||
err := json.Unmarshal(v.NetworkSettings, &inbound.StreamSetting.QUICSettings)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("unmarshal grpc settings error: %s", err)
|
|
||||||
}
|
|
||||||
case "httpupgrade":
|
case "httpupgrade":
|
||||||
err := json.Unmarshal(v.NetworkSettings, &inbound.StreamSetting.HTTPUPGRADESettings)
|
err := json.Unmarshal(v.NetworkSettings, &inbound.StreamSetting.HTTPUPGRADESettings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -38,9 +38,13 @@ func buildSSUser(tag string, userInfo *panel.UserInfo, cypher string, serverKey
|
|||||||
keyLength = 16
|
keyLength = 16
|
||||||
case "2022-blake3-aes-256-gcm":
|
case "2022-blake3-aes-256-gcm":
|
||||||
keyLength = 32
|
keyLength = 32
|
||||||
|
case "2022-blake3-chacha20-poly1305":
|
||||||
|
keyLength = 32
|
||||||
}
|
}
|
||||||
ssAccount := &shadowsocks_2022.User{
|
ssAccount := &shadowsocks_2022.User{
|
||||||
Key: base64.StdEncoding.EncodeToString([]byte(userInfo.Uuid[:keyLength])),
|
Level: 0,
|
||||||
|
Email: format.UserTag(tag, userInfo.Uuid),
|
||||||
|
Key: base64.StdEncoding.EncodeToString([]byte(userInfo.Uuid[:keyLength])),
|
||||||
}
|
}
|
||||||
return &protocol.User{
|
return &protocol.User{
|
||||||
Level: 0,
|
Level: 0,
|
||||||
|
|||||||
219
go.mod
219
go.mod
@@ -1,40 +1,42 @@
|
|||||||
module github.com/InazumaV/V2bX
|
module github.com/InazumaV/V2bX
|
||||||
|
|
||||||
go 1.22
|
go 1.23
|
||||||
|
|
||||||
toolchain go1.22.5
|
toolchain go1.23.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/apernet/hysteria/core/v2 v2.5.1-0.20240710201643-b563f3981fc6
|
github.com/apernet/hysteria/core/v2 v2.5.3-0.20241019184355-78598bfd1b0c
|
||||||
github.com/apernet/hysteria/extras/v2 v2.5.1-0.20240710201643-b563f3981fc6
|
github.com/apernet/hysteria/extras/v2 v2.5.3-0.20241019184355-78598bfd1b0c
|
||||||
github.com/beevik/ntp v1.2.0
|
github.com/beevik/ntp v1.2.0
|
||||||
github.com/fsnotify/fsnotify v1.7.0
|
github.com/fsnotify/fsnotify v1.7.0
|
||||||
github.com/go-acme/lego/v4 v4.17.4
|
github.com/go-acme/lego/v4 v4.19.3-0.20241028134924-480950181787
|
||||||
github.com/go-resty/resty/v2 v2.13.1
|
github.com/go-resty/resty/v2 v2.15.3
|
||||||
github.com/goccy/go-json v0.10.3
|
github.com/goccy/go-json v0.10.3
|
||||||
github.com/hashicorp/go-multierror v1.1.1
|
github.com/hashicorp/go-multierror v1.1.2-0.20240618221538-6fa16eae919d
|
||||||
github.com/juju/ratelimit v1.0.2
|
github.com/juju/ratelimit v1.0.2
|
||||||
github.com/sagernet/sing v0.5.0-alpha.12.0.20240717075530-332e47007567
|
github.com/sagernet/sing v0.5.0-rc.2
|
||||||
github.com/sagernet/sing-box v1.10.0-alpha.22
|
github.com/sagernet/sing-box v1.11.0-alpha.2-1
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
github.com/spf13/cobra v1.8.0
|
github.com/spf13/cobra v1.8.1
|
||||||
github.com/spf13/viper v1.15.0
|
github.com/spf13/viper v1.18.2
|
||||||
github.com/xtls/xray-core v1.8.21-0.20240721085503-22535d864399
|
github.com/xtls/xray-core v1.8.25-0.20241031075831-4ec5c78c3453
|
||||||
go.uber.org/zap v1.27.0
|
go.uber.org/zap v1.27.0
|
||||||
golang.org/x/crypto v0.25.0
|
golang.org/x/crypto v0.28.0
|
||||||
golang.org/x/sys v0.22.0
|
golang.org/x/sys v0.26.0
|
||||||
google.golang.org/protobuf v1.34.2
|
google.golang.org/protobuf v1.35.1
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
berty.tech/go-libtor v1.0.385 // indirect
|
berty.tech/go-libtor v1.0.385 // indirect
|
||||||
cloud.google.com/go/compute/metadata v0.3.0 // indirect
|
cloud.google.com/go/auth v0.9.3 // indirect
|
||||||
|
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
|
||||||
|
cloud.google.com/go/compute/metadata v0.5.1 // indirect
|
||||||
github.com/AdamSLevy/jsonrpc2/v14 v14.1.0 // indirect
|
github.com/AdamSLevy/jsonrpc2/v14 v14.1.0 // indirect
|
||||||
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
|
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0 // indirect
|
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 // indirect
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.6.0 // indirect
|
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 // indirect
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.0 // indirect
|
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0 // indirect
|
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0 // indirect
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.2.0 // indirect
|
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.2.0 // indirect
|
||||||
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.9.0 // indirect
|
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.9.0 // indirect
|
||||||
@@ -50,80 +52,80 @@ require (
|
|||||||
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
|
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
|
||||||
github.com/OpenDNS/vegadns2client v0.0.0-20180418235048-a3fa4a771d87 // indirect
|
github.com/OpenDNS/vegadns2client v0.0.0-20180418235048-a3fa4a771d87 // indirect
|
||||||
github.com/akamai/AkamaiOPEN-edgegrid-golang v1.2.2 // indirect
|
github.com/akamai/AkamaiOPEN-edgegrid-golang v1.2.2 // indirect
|
||||||
github.com/aliyun/alibaba-cloud-sdk-go v1.62.712 // indirect
|
github.com/aliyun/alibaba-cloud-sdk-go v1.63.15 // indirect
|
||||||
github.com/andybalholm/brotli v1.1.0 // indirect
|
github.com/andybalholm/brotli v1.1.0 // indirect
|
||||||
github.com/apernet/quic-go v0.45.2-0.20240702221538-ed74cfbe8b6e // indirect
|
github.com/apernet/quic-go v0.47.1-0.20241004180137-a80d14e2080d // indirect
|
||||||
github.com/aws/aws-sdk-go-v2 v1.27.2 // indirect
|
github.com/aws/aws-sdk-go-v2 v1.30.5 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/config v1.27.18 // indirect
|
github.com/aws/aws-sdk-go-v2/config v1.27.33 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/credentials v1.17.18 // indirect
|
github.com/aws/aws-sdk-go-v2/credentials v1.17.32 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.5 // indirect
|
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.13 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.9 // indirect
|
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.17 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.9 // indirect
|
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.17 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
|
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect
|
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.4 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.11 // indirect
|
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.19 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/lightsail v1.38.3 // indirect
|
github.com/aws/aws-sdk-go-v2/service/lightsail v1.40.6 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/route53 v1.40.10 // indirect
|
github.com/aws/aws-sdk-go-v2/service/route53 v1.43.2 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/sso v1.20.11 // indirect
|
github.com/aws/aws-sdk-go-v2/service/sso v1.22.7 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.24.5 // indirect
|
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.7 // indirect
|
||||||
github.com/aws/aws-sdk-go-v2/service/sts v1.28.12 // indirect
|
github.com/aws/aws-sdk-go-v2/service/sts v1.30.7 // indirect
|
||||||
github.com/aws/smithy-go v1.20.2 // indirect
|
github.com/aws/smithy-go v1.20.4 // indirect
|
||||||
github.com/babolivier/go-doh-client v0.0.0-20201028162107-a76cff4cb8b6 // indirect
|
github.com/babolivier/go-doh-client v0.0.0-20201028162107-a76cff4cb8b6 // indirect
|
||||||
github.com/benbjohnson/clock v1.3.0 // indirect
|
github.com/benbjohnson/clock v1.3.0 // indirect
|
||||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
|
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
|
||||||
github.com/caddyserver/certmagic v0.20.0 // indirect
|
github.com/caddyserver/certmagic v0.20.0 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||||
github.com/civo/civogo v0.3.11 // indirect
|
github.com/civo/civogo v0.3.11 // indirect
|
||||||
github.com/cloudflare/circl v1.3.9 // indirect
|
github.com/cloudflare/circl v1.4.0 // indirect
|
||||||
github.com/cloudflare/cloudflare-go v0.97.0 // indirect
|
github.com/cloudflare/cloudflare-go v0.104.0 // indirect
|
||||||
github.com/cpu/goacmedns v0.1.1 // indirect
|
github.com/cpu/goacmedns v0.1.1 // indirect
|
||||||
github.com/cretz/bine v0.2.0 // indirect
|
github.com/cretz/bine v0.2.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||||
github.com/deepmap/oapi-codegen v1.9.1 // indirect
|
|
||||||
github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect
|
github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect
|
||||||
github.com/dimchansky/utfbom v1.1.1 // indirect
|
github.com/dimchansky/utfbom v1.1.1 // indirect
|
||||||
github.com/dnsimple/dnsimple-go v1.7.0 // indirect
|
github.com/dnsimple/dnsimple-go v1.7.0 // indirect
|
||||||
github.com/exoscale/egoscale v0.102.3 // indirect
|
github.com/exoscale/egoscale/v3 v3.1.5 // indirect
|
||||||
github.com/fatih/structs v1.1.0 // indirect
|
github.com/fatih/structs v1.1.0 // indirect
|
||||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||||
github.com/francoispqt/gojay v1.2.13 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||||
github.com/gaukas/godicttls v0.0.4 // indirect
|
|
||||||
github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 // indirect
|
github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 // indirect
|
||||||
github.com/go-chi/chi/v5 v5.0.12 // indirect
|
github.com/go-chi/chi/v5 v5.1.0 // indirect
|
||||||
github.com/go-errors/errors v1.0.1 // indirect
|
github.com/go-errors/errors v1.0.1 // indirect
|
||||||
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
|
github.com/go-jose/go-jose/v4 v4.0.4 // indirect
|
||||||
github.com/go-logr/logr v1.4.1 // indirect
|
github.com/go-logr/logr v1.4.2 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||||
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
|
github.com/go-playground/validator/v10 v10.16.0 // indirect
|
||||||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
||||||
github.com/go-viper/mapstructure/v2 v2.0.0 // indirect
|
github.com/go-viper/mapstructure/v2 v2.1.0 // indirect
|
||||||
github.com/gobwas/httphead v0.1.0 // indirect
|
github.com/gobwas/httphead v0.1.0 // indirect
|
||||||
github.com/gobwas/pool v0.2.1 // indirect
|
github.com/gobwas/pool v0.2.1 // indirect
|
||||||
github.com/gofrs/flock v0.8.1 // indirect
|
github.com/gofrs/flock v0.12.1 // indirect
|
||||||
github.com/gofrs/uuid v4.4.0+incompatible // indirect
|
github.com/gofrs/uuid/v5 v5.3.0 // indirect
|
||||||
github.com/gofrs/uuid/v5 v5.2.0 // indirect
|
|
||||||
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
|
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
|
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||||
github.com/golang/protobuf v1.5.4 // indirect
|
|
||||||
github.com/google/btree v1.1.2 // indirect
|
github.com/google/btree v1.1.2 // indirect
|
||||||
github.com/google/go-cmp v0.6.0 // indirect
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
github.com/google/go-querystring v1.1.0 // indirect
|
github.com/google/go-querystring v1.1.0 // indirect
|
||||||
github.com/google/pprof v0.0.0-20240528025155-186aa0362fba // indirect
|
github.com/google/pprof v0.0.0-20240528025155-186aa0362fba // indirect
|
||||||
github.com/google/s2a-go v0.1.7 // indirect
|
github.com/google/s2a-go v0.1.8 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
|
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
|
||||||
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
|
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
|
||||||
github.com/gophercloud/gophercloud v1.12.0 // indirect
|
github.com/gophercloud/gophercloud v1.14.0 // indirect
|
||||||
github.com/gophercloud/utils v0.0.0-20231010081019-80377eca5d56 // indirect
|
github.com/gophercloud/utils v0.0.0-20231010081019-80377eca5d56 // indirect
|
||||||
github.com/gorilla/websocket v1.5.3 // indirect
|
github.com/gorilla/websocket v1.5.3 // indirect
|
||||||
github.com/hashicorp/errwrap v1.0.0 // indirect
|
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||||
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
|
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
|
||||||
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.5 // indirect
|
github.com/hashicorp/golang-lru/v2 v2.0.5 // indirect
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
github.com/hashicorp/yamux v0.1.1 // indirect
|
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||||
|
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.114 // indirect
|
||||||
github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df // indirect
|
github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/infobloxopen/infoblox-go-client v1.1.1 // indirect
|
github.com/infobloxopen/infoblox-go-client v1.1.1 // indirect
|
||||||
@@ -137,10 +139,11 @@ require (
|
|||||||
github.com/kylelemons/godebug v1.1.0 // indirect
|
github.com/kylelemons/godebug v1.1.0 // indirect
|
||||||
github.com/labbsr0x/bindman-dns-webhook v1.0.2 // indirect
|
github.com/labbsr0x/bindman-dns-webhook v1.0.2 // indirect
|
||||||
github.com/labbsr0x/goh v1.0.1 // indirect
|
github.com/labbsr0x/goh v1.0.1 // indirect
|
||||||
|
github.com/leodido/go-urn v1.2.4 // indirect
|
||||||
github.com/libdns/alidns v1.0.3 // indirect
|
github.com/libdns/alidns v1.0.3 // indirect
|
||||||
github.com/libdns/cloudflare v0.1.1 // indirect
|
github.com/libdns/cloudflare v0.1.1 // indirect
|
||||||
github.com/libdns/libdns v0.2.2 // indirect
|
github.com/libdns/libdns v0.2.2 // indirect
|
||||||
github.com/linode/linodego v1.28.0 // indirect
|
github.com/linode/linodego v1.40.0 // indirect
|
||||||
github.com/liquidweb/liquidweb-cli v0.6.9 // indirect
|
github.com/liquidweb/liquidweb-cli v0.6.9 // indirect
|
||||||
github.com/liquidweb/liquidweb-go v1.6.4 // indirect
|
github.com/liquidweb/liquidweb-go v1.6.4 // indirect
|
||||||
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
|
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
|
||||||
@@ -148,8 +151,9 @@ require (
|
|||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/mdlayher/netlink v1.7.2 // indirect
|
github.com/mdlayher/netlink v1.7.2 // indirect
|
||||||
github.com/mdlayher/socket v0.4.1 // indirect
|
github.com/mdlayher/socket v0.4.1 // indirect
|
||||||
|
github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa // indirect
|
||||||
github.com/mholt/acmez v1.2.0 // indirect
|
github.com/mholt/acmez v1.2.0 // indirect
|
||||||
github.com/miekg/dns v1.1.61 // indirect
|
github.com/miekg/dns v1.1.62 // indirect
|
||||||
github.com/mimuret/golang-iij-dpf v0.9.1 // indirect
|
github.com/mimuret/golang-iij-dpf v0.9.1 // indirect
|
||||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
@@ -165,24 +169,24 @@ require (
|
|||||||
github.com/nrdcg/mailinabox v0.2.0 // indirect
|
github.com/nrdcg/mailinabox v0.2.0 // indirect
|
||||||
github.com/nrdcg/namesilo v0.2.1 // indirect
|
github.com/nrdcg/namesilo v0.2.1 // indirect
|
||||||
github.com/nrdcg/nodion v0.1.0 // indirect
|
github.com/nrdcg/nodion v0.1.0 // indirect
|
||||||
github.com/nrdcg/porkbun v0.3.0 // indirect
|
github.com/nrdcg/porkbun v0.4.0 // indirect
|
||||||
github.com/nzdjb/go-metaname v1.0.0 // indirect
|
github.com/nzdjb/go-metaname v1.0.0 // indirect
|
||||||
github.com/onsi/ginkgo/v2 v2.19.0 // indirect
|
github.com/onsi/ginkgo/v2 v2.19.0 // indirect
|
||||||
github.com/ooni/go-libtor v1.1.8 // indirect
|
github.com/ooni/go-libtor v1.1.8 // indirect
|
||||||
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
|
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
|
||||||
github.com/oracle/oci-go-sdk/v65 v65.63.1 // indirect
|
github.com/oracle/oci-go-sdk/v65 v65.73.0 // indirect
|
||||||
github.com/oschwald/maxminddb-golang v1.12.0 // indirect
|
github.com/oschwald/maxminddb-golang v1.12.0 // indirect
|
||||||
github.com/ovh/go-ovh v1.5.1 // indirect
|
github.com/ovh/go-ovh v1.6.0 // indirect
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
|
||||||
github.com/pires/go-proxyproto v0.7.0 // indirect
|
github.com/pires/go-proxyproto v0.8.0 // indirect
|
||||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||||
github.com/pquerna/otp v1.4.0 // indirect
|
github.com/pquerna/otp v1.4.0 // indirect
|
||||||
github.com/quic-go/qpack v0.4.0 // indirect
|
github.com/quic-go/qpack v0.5.1 // indirect
|
||||||
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
|
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
|
||||||
github.com/quic-go/quic-go v0.45.1 // indirect
|
github.com/quic-go/quic-go v0.46.0 // indirect
|
||||||
github.com/refraction-networking/utls v1.6.7 // indirect
|
github.com/refraction-networking/utls v1.6.7 // indirect
|
||||||
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect
|
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect
|
||||||
github.com/sacloud/api-client-go v0.2.10 // indirect
|
github.com/sacloud/api-client-go v0.2.10 // indirect
|
||||||
@@ -195,22 +199,23 @@ require (
|
|||||||
github.com/sagernet/gvisor v0.0.0-20240428053021-e691de28565f // indirect
|
github.com/sagernet/gvisor v0.0.0-20240428053021-e691de28565f // indirect
|
||||||
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a // indirect
|
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a // indirect
|
||||||
github.com/sagernet/nftables v0.3.0-beta.4 // indirect
|
github.com/sagernet/nftables v0.3.0-beta.4 // indirect
|
||||||
github.com/sagernet/quic-go v0.45.1-beta.2 // indirect
|
github.com/sagernet/quic-go v0.48.0-beta.1 // indirect
|
||||||
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 // indirect
|
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 // indirect
|
||||||
github.com/sagernet/sing-dns v0.3.0-beta.10 // indirect
|
github.com/sagernet/sing-dns v0.3.0-rc.2 // indirect
|
||||||
github.com/sagernet/sing-mux v0.2.0 // indirect
|
github.com/sagernet/sing-mux v0.2.0 // indirect
|
||||||
github.com/sagernet/sing-quic v0.2.0-beta.12 // indirect
|
github.com/sagernet/sing-quic v0.3.0-rc.1 // indirect
|
||||||
github.com/sagernet/sing-shadowsocks v0.2.7 // indirect
|
github.com/sagernet/sing-shadowsocks v0.2.7 // indirect
|
||||||
github.com/sagernet/sing-shadowsocks2 v0.2.0 // indirect
|
github.com/sagernet/sing-shadowsocks2 v0.2.0 // indirect
|
||||||
github.com/sagernet/sing-shadowtls v0.1.4 // indirect
|
github.com/sagernet/sing-shadowtls v0.1.4 // indirect
|
||||||
github.com/sagernet/sing-tun v0.4.0-beta.13.0.20240703164908-1f043289199d // indirect
|
github.com/sagernet/sing-tun v0.4.0-rc.4 // indirect
|
||||||
github.com/sagernet/sing-vmess v0.1.12 // indirect
|
github.com/sagernet/sing-vmess v0.1.12 // indirect
|
||||||
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect
|
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect
|
||||||
github.com/sagernet/tfo-go v0.0.0-20231209031829-7b5343ac1dc6 // indirect
|
github.com/sagernet/utls v1.6.7 // indirect
|
||||||
github.com/sagernet/utls v1.5.4 // indirect
|
|
||||||
github.com/sagernet/wireguard-go v0.0.0-20231215174105-89dec3b2f3e8 // indirect
|
github.com/sagernet/wireguard-go v0.0.0-20231215174105-89dec3b2f3e8 // indirect
|
||||||
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854 // indirect
|
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854 // indirect
|
||||||
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.27 // indirect
|
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||||
|
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||||
|
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.30 // indirect
|
||||||
github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 // indirect
|
github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 // indirect
|
||||||
github.com/selectel/domains-go v1.1.0 // indirect
|
github.com/selectel/domains-go v1.1.0 // indirect
|
||||||
github.com/selectel/go-selvpcclient/v3 v3.1.1 // indirect
|
github.com/selectel/go-selvpcclient/v3 v3.1.1 // indirect
|
||||||
@@ -219,58 +224,62 @@ require (
|
|||||||
github.com/softlayer/softlayer-go v1.1.5 // indirect
|
github.com/softlayer/softlayer-go v1.1.5 // indirect
|
||||||
github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e // indirect
|
github.com/softlayer/xmlrpc v0.0.0-20200409220501-5f089df7cb7e // indirect
|
||||||
github.com/sony/gobreaker v0.5.0 // indirect
|
github.com/sony/gobreaker v0.5.0 // indirect
|
||||||
github.com/spf13/afero v1.9.3 // indirect
|
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||||
github.com/spf13/cast v1.5.0 // indirect
|
github.com/spf13/afero v1.11.0 // indirect
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
github.com/spf13/cast v1.6.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
github.com/stretchr/objx v0.5.2 // indirect
|
github.com/stretchr/objx v0.5.2 // indirect
|
||||||
github.com/stretchr/testify v1.9.0 // indirect
|
github.com/stretchr/testify v1.9.0 // indirect
|
||||||
github.com/subosito/gotenv v1.4.2 // indirect
|
github.com/subosito/gotenv v1.6.0 // indirect
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.898 // indirect
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1002 // indirect
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.898 // indirect
|
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.1002 // indirect
|
||||||
github.com/transip/gotransip/v6 v6.23.0 // indirect
|
github.com/tjfoc/gmsm v1.4.1 // indirect
|
||||||
|
github.com/transip/gotransip/v6 v6.26.0 // indirect
|
||||||
github.com/txthinking/runnergroup v0.0.0-20210608031112-152c7c4432bf // indirect
|
github.com/txthinking/runnergroup v0.0.0-20210608031112-152c7c4432bf // indirect
|
||||||
github.com/txthinking/socks5 v0.0.0-20230325130024-4230056ae301 // indirect
|
github.com/txthinking/socks5 v0.0.0-20230325130024-4230056ae301 // indirect
|
||||||
github.com/ultradns/ultradns-go-sdk v1.6.1-20231103022937-8589b6a // indirect
|
github.com/ultradns/ultradns-go-sdk v1.7.0-20240913052650-970ca9a // indirect
|
||||||
github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e // indirect
|
github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e // indirect
|
||||||
github.com/vinyldns/go-vinyldns v0.9.16 // indirect
|
github.com/vinyldns/go-vinyldns v0.9.16 // indirect
|
||||||
github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 // indirect
|
github.com/vishvananda/netlink v1.3.0 // indirect
|
||||||
github.com/vishvananda/netns v0.0.4 // indirect
|
github.com/vishvananda/netns v0.0.4 // indirect
|
||||||
github.com/vultr/govultr/v2 v2.17.2 // indirect
|
github.com/volcengine/volc-sdk-golang v1.0.177 // indirect
|
||||||
github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d // indirect
|
github.com/vultr/govultr/v3 v3.9.1 // indirect
|
||||||
github.com/yandex-cloud/go-genproto v0.0.0-20240318083951-4fe6125f286e // indirect
|
github.com/xtls/reality v0.0.0-20240909153216-e26ae2305463 // indirect
|
||||||
github.com/yandex-cloud/go-sdk v0.0.0-20240318084659-dfa50323a0b4 // indirect
|
github.com/yandex-cloud/go-genproto v0.0.0-20240911120709-1fa0cb6f47c2 // indirect
|
||||||
|
github.com/yandex-cloud/go-sdk v0.0.0-20240911121212-e4e74d0d02f5 // indirect
|
||||||
github.com/zeebo/blake3 v0.2.3 // indirect
|
github.com/zeebo/blake3 v0.2.3 // indirect
|
||||||
|
go.mongodb.org/mongo-driver v1.12.0 // indirect
|
||||||
go.opencensus.io v0.24.0 // indirect
|
go.opencensus.io v0.24.0 // indirect
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
|
||||||
go.opentelemetry.io/otel v1.24.0 // indirect
|
go.opentelemetry.io/otel v1.29.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.24.0 // indirect
|
go.opentelemetry.io/otel/metric v1.29.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
go.opentelemetry.io/otel/trace v1.29.0 // indirect
|
||||||
go.uber.org/mock v0.4.0 // indirect
|
go.uber.org/mock v0.4.0 // indirect
|
||||||
go.uber.org/multierr v1.11.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
go.uber.org/ratelimit v0.3.0 // indirect
|
go.uber.org/ratelimit v0.3.0 // indirect
|
||||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
|
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
|
||||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
|
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
|
||||||
golang.org/x/mod v0.18.0 // indirect
|
golang.org/x/mod v0.21.0 // indirect
|
||||||
golang.org/x/net v0.27.0 // indirect
|
golang.org/x/net v0.30.0 // indirect
|
||||||
golang.org/x/oauth2 v0.21.0 // indirect
|
golang.org/x/oauth2 v0.23.0 // indirect
|
||||||
golang.org/x/sync v0.7.0 // indirect
|
golang.org/x/sync v0.8.0 // indirect
|
||||||
golang.org/x/text v0.16.0 // indirect
|
golang.org/x/text v0.19.0 // indirect
|
||||||
golang.org/x/time v0.5.0 // indirect
|
golang.org/x/time v0.6.0 // indirect
|
||||||
golang.org/x/tools v0.22.0 // indirect
|
golang.org/x/tools v0.25.0 // indirect
|
||||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
|
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
|
||||||
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 // indirect
|
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 // indirect
|
||||||
google.golang.org/api v0.172.0 // indirect
|
google.golang.org/api v0.197.0 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
|
google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20240827150818-7e3bb234dfed // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||||
google.golang.org/grpc v1.65.0 // indirect
|
google.golang.org/grpc v1.67.1 // indirect
|
||||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||||
gopkg.in/ns1/ns1-go.v2 v2.7.13 // indirect
|
gopkg.in/ns1/ns1-go.v2 v2.12.0 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 // indirect
|
gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 // indirect
|
||||||
lukechampine.com/blake3 v1.3.0 // indirect
|
lukechampine.com/blake3 v1.3.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/sagernet/sing-box v1.10.0-alpha.22 => github.com/wyx2685/sing-box_mod v1.10.0-alpha.22
|
// replace github.com/sagernet/sing-box v1.10.0-alpha.22 => /root/sing-box_mod
|
||||||
|
replace github.com/sagernet/sing-box v1.11.0-alpha.2-1 => github.com/wyx2685/sing-box_mod v1.11.0-alpha.2-1
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package limiter
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -20,13 +21,13 @@ var limiter map[string]*Limiter
|
|||||||
func Init() {
|
func Init() {
|
||||||
limiter = map[string]*Limiter{}
|
limiter = map[string]*Limiter{}
|
||||||
c := task.Periodic{
|
c := task.Periodic{
|
||||||
Interval: time.Minute * 2,
|
Interval: time.Minute * 3,
|
||||||
Execute: ClearOnlineIP,
|
Execute: ClearOnlineIP,
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
log.WithField("Type", "Limiter").
|
log.WithField("Type", "Limiter").
|
||||||
Debug("ClearOnlineIP started")
|
Debug("ClearOnlineIP started")
|
||||||
time.Sleep(time.Minute * 2)
|
time.Sleep(time.Minute * 3)
|
||||||
_ = c.Start()
|
_ = c.Start()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
@@ -36,10 +37,12 @@ type Limiter struct {
|
|||||||
ProtocolRules []string
|
ProtocolRules []string
|
||||||
SpeedLimit int
|
SpeedLimit int
|
||||||
UserOnlineIP *sync.Map // Key: Name, value: {Key: Ip, value: Uid}
|
UserOnlineIP *sync.Map // Key: Name, value: {Key: Ip, value: Uid}
|
||||||
UUIDtoUID map[string]int // Key: UUID, value: UID
|
OldUserOnline map[string]int // Key: Ip, value: Uid
|
||||||
|
UUIDtoUID map[string]int // Key: UUID, value: Uid
|
||||||
UserLimitInfo *sync.Map // Key: Uid value: UserLimitInfo
|
UserLimitInfo *sync.Map // Key: Uid value: UserLimitInfo
|
||||||
ConnLimiter *ConnLimiter // Key: Uid value: ConnLimiter
|
ConnLimiter *ConnLimiter // Key: Uid value: ConnLimiter
|
||||||
SpeedLimiter *sync.Map // key: Uid, value: *ratelimit.Bucket
|
SpeedLimiter *sync.Map // key: Uid, value: *ratelimit.Bucket
|
||||||
|
AliveList map[int]int // Key: Uid, value: alive_ip
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserLimitInfo struct {
|
type UserLimitInfo struct {
|
||||||
@@ -51,13 +54,15 @@ type UserLimitInfo struct {
|
|||||||
OverLimit bool
|
OverLimit bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddLimiter(tag string, l *conf.LimitConfig, users []panel.UserInfo) *Limiter {
|
func AddLimiter(tag string, l *conf.LimitConfig, users []panel.UserInfo, aliveList map[int]int) *Limiter {
|
||||||
info := &Limiter{
|
info := &Limiter{
|
||||||
SpeedLimit: l.SpeedLimit,
|
SpeedLimit: l.SpeedLimit,
|
||||||
UserOnlineIP: new(sync.Map),
|
UserOnlineIP: new(sync.Map),
|
||||||
UserLimitInfo: new(sync.Map),
|
UserLimitInfo: new(sync.Map),
|
||||||
ConnLimiter: NewConnLimiter(l.ConnLimit, l.IPLimit, l.EnableRealtime),
|
ConnLimiter: NewConnLimiter(l.ConnLimit, l.IPLimit, l.EnableRealtime),
|
||||||
SpeedLimiter: new(sync.Map),
|
SpeedLimiter: new(sync.Map),
|
||||||
|
AliveList: aliveList,
|
||||||
|
OldUserOnline: make(map[string]int),
|
||||||
}
|
}
|
||||||
uuidmap := make(map[string]int)
|
uuidmap := make(map[string]int)
|
||||||
for i := range users {
|
for i := range users {
|
||||||
@@ -99,7 +104,9 @@ func DeleteLimiter(tag string) {
|
|||||||
func (l *Limiter) UpdateUser(tag string, added []panel.UserInfo, deleted []panel.UserInfo) {
|
func (l *Limiter) UpdateUser(tag string, added []panel.UserInfo, deleted []panel.UserInfo) {
|
||||||
for i := range deleted {
|
for i := range deleted {
|
||||||
l.UserLimitInfo.Delete(format.UserTag(tag, deleted[i].Uuid))
|
l.UserLimitInfo.Delete(format.UserTag(tag, deleted[i].Uuid))
|
||||||
|
l.UserOnlineIP.Delete(format.UserTag(tag, deleted[i].Uuid))
|
||||||
delete(l.UUIDtoUID, deleted[i].Uuid)
|
delete(l.UUIDtoUID, deleted[i].Uuid)
|
||||||
|
delete(l.AliveList, deleted[i].Id)
|
||||||
}
|
}
|
||||||
for i := range added {
|
for i := range added {
|
||||||
userLimit := &UserLimitInfo{
|
userLimit := &UserLimitInfo{
|
||||||
@@ -129,7 +136,10 @@ func (l *Limiter) UpdateDynamicSpeedLimit(tag, uuid string, limit int, expire ti
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Limiter) CheckLimit(taguuid string, ip string, isTcp bool) (Bucket *ratelimit.Bucket, Reject bool) {
|
func (l *Limiter) CheckLimit(taguuid string, ip string, isTcp bool, noSSUDP bool) (Bucket *ratelimit.Bucket, Reject bool) {
|
||||||
|
// check if ipv4 mapped ipv6
|
||||||
|
ip = strings.TrimPrefix(ip, "::ffff:")
|
||||||
|
|
||||||
// ip and conn limiter
|
// ip and conn limiter
|
||||||
if l.ConnLimiter.AddConnCount(taguuid, ip, isTcp) {
|
if l.ConnLimiter.AddConnCount(taguuid, ip, isTcp) {
|
||||||
return nil, true
|
return nil, true
|
||||||
@@ -155,23 +165,31 @@ func (l *Limiter) CheckLimit(taguuid string, ip string, isTcp bool) (Bucket *rat
|
|||||||
userLimit = determineSpeedLimit(u.SpeedLimit, u.DynamicSpeedLimit)
|
userLimit = determineSpeedLimit(u.SpeedLimit, u.DynamicSpeedLimit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if noSSUDP {
|
||||||
// Store online user for device limit
|
// Store online user for device limit
|
||||||
ipMap := new(sync.Map)
|
ipMap := new(sync.Map)
|
||||||
ipMap.Store(ip, uid)
|
ipMap.Store(ip, uid)
|
||||||
// If any device is online
|
aliveIp := l.AliveList[uid]
|
||||||
if v, ok := l.UserOnlineIP.LoadOrStore(taguuid, ipMap); ok {
|
// If any device is online
|
||||||
ipMap := v.(*sync.Map)
|
if v, ok := l.UserOnlineIP.LoadOrStore(taguuid, ipMap); ok {
|
||||||
// If this is a new ip
|
ipMap := v.(*sync.Map)
|
||||||
if _, ok := ipMap.LoadOrStore(ip, uid); !ok {
|
// If this is a new ip
|
||||||
counter := 0
|
if _, ok := ipMap.LoadOrStore(ip, uid); !ok {
|
||||||
ipMap.Range(func(key, value interface{}) bool {
|
if deviceLimit > 0 {
|
||||||
counter++
|
if deviceLimit <= aliveIp {
|
||||||
return true
|
ipMap.Delete(ip)
|
||||||
})
|
return nil, true
|
||||||
if counter > deviceLimit && deviceLimit > 0 {
|
}
|
||||||
ipMap.Delete(ip)
|
}
|
||||||
return nil, true
|
}
|
||||||
|
} else if l.OldUserOnline[ip] == uid {
|
||||||
|
delete(l.OldUserOnline, ip)
|
||||||
|
} else {
|
||||||
|
if deviceLimit > 0 {
|
||||||
|
if deviceLimit <= aliveIp {
|
||||||
|
l.UserOnlineIP.Delete(taguuid)
|
||||||
|
return nil, true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,17 +210,17 @@ func (l *Limiter) CheckLimit(taguuid string, ip string, isTcp bool) (Bucket *rat
|
|||||||
|
|
||||||
func (l *Limiter) GetOnlineDevice() (*[]panel.OnlineUser, error) {
|
func (l *Limiter) GetOnlineDevice() (*[]panel.OnlineUser, error) {
|
||||||
var onlineUser []panel.OnlineUser
|
var onlineUser []panel.OnlineUser
|
||||||
|
|
||||||
l.UserOnlineIP.Range(func(key, value interface{}) bool {
|
l.UserOnlineIP.Range(func(key, value interface{}) bool {
|
||||||
email := key.(string)
|
taguuid := key.(string)
|
||||||
ipMap := value.(*sync.Map)
|
ipMap := value.(*sync.Map)
|
||||||
ipMap.Range(func(key, value interface{}) bool {
|
ipMap.Range(func(key, value interface{}) bool {
|
||||||
uid := value.(int)
|
uid := value.(int)
|
||||||
ip := key.(string)
|
ip := key.(string)
|
||||||
|
l.OldUserOnline[ip] = uid
|
||||||
onlineUser = append(onlineUser, panel.OnlineUser{UID: uid, IP: ip})
|
onlineUser = append(onlineUser, panel.OnlineUser{UID: uid, IP: ip})
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
l.UserOnlineIP.Delete(email) // Reset online device
|
l.UserOnlineIP.Delete(taguuid) // Reset online device
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -213,23 +231,3 @@ type UserIpList struct {
|
|||||||
Uid int `json:"Uid"`
|
Uid int `json:"Uid"`
|
||||||
IpList []string `json:"Ips"`
|
IpList []string `json:"Ips"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func determineDeviceLimit(nodeLimit, userLimit int) (limit int) {
|
|
||||||
if nodeLimit == 0 || userLimit == 0 {
|
|
||||||
if nodeLimit > userLimit {
|
|
||||||
return nodeLimit
|
|
||||||
} else if nodeLimit < userLimit {
|
|
||||||
return userLimit
|
|
||||||
} else {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if nodeLimit > userLimit {
|
|
||||||
return userLimit
|
|
||||||
} else if nodeLimit < userLimit {
|
|
||||||
return nodeLimit
|
|
||||||
} else {
|
|
||||||
return nodeLimit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
7
main.go
7
main.go
@@ -1,16 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
//"net/http"
|
|
||||||
//_ "net/http/pprof"
|
|
||||||
|
|
||||||
"github.com/InazumaV/V2bX/cmd"
|
"github.com/InazumaV/V2bX/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
//内存泄漏排查
|
|
||||||
//go func() {
|
|
||||||
// http.ListenAndServe("127.0.0.1:6060", nil)
|
|
||||||
//}()
|
|
||||||
cmd.Run()
|
cmd.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ type Controller struct {
|
|||||||
limiter *limiter.Limiter
|
limiter *limiter.Limiter
|
||||||
traffic map[string]int64
|
traffic map[string]int64
|
||||||
userList []panel.UserInfo
|
userList []panel.UserInfo
|
||||||
|
aliveMap map[int]int
|
||||||
info *panel.NodeInfo
|
info *panel.NodeInfo
|
||||||
nodeInfoMonitorPeriodic *task.Task
|
nodeInfoMonitorPeriodic *task.Task
|
||||||
userReportPeriodic *task.Task
|
userReportPeriodic *task.Task
|
||||||
@@ -54,6 +55,10 @@ func (c *Controller) Start() error {
|
|||||||
if len(c.userList) == 0 {
|
if len(c.userList) == 0 {
|
||||||
return errors.New("add users error: not have any user")
|
return errors.New("add users error: not have any user")
|
||||||
}
|
}
|
||||||
|
c.aliveMap, err = c.apiClient.GetUserAlive()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to get user alive list: %s", err)
|
||||||
|
}
|
||||||
if len(c.Options.Name) == 0 {
|
if len(c.Options.Name) == 0 {
|
||||||
c.tag = c.buildNodeTag(node)
|
c.tag = c.buildNodeTag(node)
|
||||||
} else {
|
} else {
|
||||||
@@ -61,7 +66,7 @@ func (c *Controller) Start() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add limiter
|
// add limiter
|
||||||
l := limiter.AddLimiter(c.tag, &c.LimitConfig, c.userList)
|
l := limiter.AddLimiter(c.tag, &c.LimitConfig, c.userList, c.aliveMap)
|
||||||
// add rule limiter
|
// add rule limiter
|
||||||
if err = l.UpdateRule(&node.Rules); err != nil {
|
if err = l.UpdateRule(&node.Rules); err != nil {
|
||||||
return fmt.Errorf("update rule error: %s", err)
|
return fmt.Errorf("update rule error: %s", err)
|
||||||
|
|||||||
12
node/task.go
12
node/task.go
@@ -68,6 +68,11 @@ func (c *Controller) nodeInfoMonitor() (err error) {
|
|||||||
}).Error("Get user list failed")
|
}).Error("Get user list failed")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
// get user alive
|
||||||
|
newA, err := c.apiClient.GetUserAlive()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if newN != nil {
|
if newN != nil {
|
||||||
c.info = newN
|
c.info = newN
|
||||||
// nodeInfo changed
|
// nodeInfo changed
|
||||||
@@ -92,7 +97,7 @@ func (c *Controller) nodeInfoMonitor() (err error) {
|
|||||||
// Remove Old limiter
|
// Remove Old limiter
|
||||||
limiter.DeleteLimiter(c.tag)
|
limiter.DeleteLimiter(c.tag)
|
||||||
// Add new Limiter
|
// Add new Limiter
|
||||||
l := limiter.AddLimiter(c.tag, &c.LimitConfig, c.userList)
|
l := limiter.AddLimiter(c.tag, &c.LimitConfig, c.userList, newA)
|
||||||
c.limiter = l
|
c.limiter = l
|
||||||
}
|
}
|
||||||
// Update rule
|
// Update rule
|
||||||
@@ -154,7 +159,10 @@ func (c *Controller) nodeInfoMonitor() (err error) {
|
|||||||
// exit
|
// exit
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
// update alive list
|
||||||
|
if newA != nil {
|
||||||
|
c.limiter.AliveList = newA
|
||||||
|
}
|
||||||
// node no changed, check users
|
// node no changed, check users
|
||||||
if len(newU) == 0 {
|
if len(newU) == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
14
node/user.go
14
node/user.go
@@ -14,11 +14,7 @@ func (c *Controller) reportUserTrafficTask() (err error) {
|
|||||||
up, down := c.server.GetUserTraffic(c.tag, c.userList[i].Uuid, true)
|
up, down := c.server.GetUserTraffic(c.tag, c.userList[i].Uuid, true)
|
||||||
if up > 0 || down > 0 {
|
if up > 0 || down > 0 {
|
||||||
if c.LimitConfig.EnableDynamicSpeedLimit {
|
if c.LimitConfig.EnableDynamicSpeedLimit {
|
||||||
if _, ok := c.traffic[c.userList[i].Uuid]; ok {
|
c.traffic[c.userList[i].Uuid] += up + down
|
||||||
c.traffic[c.userList[i].Uuid] += up + down
|
|
||||||
} else {
|
|
||||||
c.traffic[c.userList[i].Uuid] = up + down
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
userTraffic = append(userTraffic, panel.UserTraffic{
|
userTraffic = append(userTraffic, panel.UserTraffic{
|
||||||
UID: (c.userList)[i].Id,
|
UID: (c.userList)[i].Id,
|
||||||
@@ -55,18 +51,12 @@ func (c *Controller) reportUserTrafficTask() (err error) {
|
|||||||
result = append(result, online)
|
result = append(result, online)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reportOnline := make(map[int]int)
|
|
||||||
data := make(map[int][]string)
|
data := make(map[int][]string)
|
||||||
for _, onlineuser := range result {
|
for _, onlineuser := range result {
|
||||||
// json structure: { UID1:["ip1","ip2"],UID2:["ip3","ip4"] }
|
// json structure: { UID1:["ip1","ip2"],UID2:["ip3","ip4"] }
|
||||||
data[onlineuser.UID] = append(data[onlineuser.UID], onlineuser.IP)
|
data[onlineuser.UID] = append(data[onlineuser.UID], onlineuser.IP)
|
||||||
if _, ok := reportOnline[onlineuser.UID]; ok {
|
|
||||||
reportOnline[onlineuser.UID]++
|
|
||||||
} else {
|
|
||||||
reportOnline[onlineuser.UID] = 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if err = c.apiClient.ReportNodeOnlineUsers(&data, &reportOnline); err != nil {
|
if err = c.apiClient.ReportNodeOnlineUsers(&data); err != nil {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"tag": c.tag,
|
"tag": c.tag,
|
||||||
"err": err,
|
"err": err,
|
||||||
|
|||||||
Reference in New Issue
Block a user