Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增功能 by CoCoding #202

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ x-ui-*.tar.gz
/release.sh
.sync*
main
.DS_Store
bin/x-ui
bin/upload.sh
38 changes: 38 additions & 0 deletions CoCoding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Co-coding 扩展功能

## 本地开发
> `go get -u` 更新开发包
- 启动Web服务
`go run main.go run`
- 测试

打开网址
> http://127.0.0.1:54321

- Macbook m1 arm64 开发

[https://github.com/XTLS/Xray-core/releases](https://github.com/XTLS/Xray-core/releases) 下载xray-core,放在bin目录下,重命名为 `xray-darwin-amd64`

- 升级go1.22.2
- go mod tidy

## 添加功能

- 快捷配置

> 快捷配置能够配置一些常用参数,例如:入站端口范围、入站TLS证书,以免每次添加入站节点时需要手动输入。

- 节点复制

> 入站节点操作增加复制功能,可以快速复制节点信息,端口和ID会重新生成,主要复制TLS证书信息。

- 订阅功能

> 添加订阅,订阅包括多个节点,可设置自动更新,防止端口被墙,可生成订阅链接,可设置有效日期


## 安装&升级

```
bash <(curl -Ls https://github.com/icocoding/x-ui/releases/download/tools/install-v1.0.sh)
```
2 changes: 1 addition & 1 deletion config/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.2
0.3.3
16 changes: 13 additions & 3 deletions database/db.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package database

import (
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"github.com/glebarez/sqlite"
// "github.com/glebarez/sqlite"
"io/fs"
"os"
"path"
"x-ui/config"
"x-ui/database/model"

"gorm.io/gorm"
"gorm.io/gorm/logger"
)

var db *gorm.DB
Expand Down Expand Up @@ -41,6 +43,10 @@ func initSetting() error {
return db.AutoMigrate(&model.Setting{})
}

func initSubscription() error {
return db.AutoMigrate(&model.Subscription{})
}

func InitDB(dbPath string) error {
dir := path.Dir(dbPath)
err := os.MkdirAll(dir, fs.ModeDir)
Expand Down Expand Up @@ -76,6 +82,10 @@ func InitDB(dbPath string) error {
if err != nil {
return err
}
err = initSubscription()
if err != nil {
return err
}

return nil
}
Expand Down
17 changes: 17 additions & 0 deletions database/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,20 @@ type Setting struct {
Key string `json:"key" form:"key"`
Value string `json:"value" form:"value"`
}


type Subscription struct {
Id int `json:"id" form:"id" gorm:"primaryKey;autoIncrement"`
UserId int `json:"-"`
Token string `json:"token" form:"token" gorm:"unique"`
Remark string `json:"remark" form:"remark"`
Enable bool `json:"enable" form:"enable"`
ExpiryTime int64 `json:"expiryTime" form:"expiryTime"`

// Inbound Config
SampleId int `json:"sampleId" form:"sampleId"`
AvailableCount int `json:"availableCount" form:"availableCount"`
AutoUpdate bool `json:"autoUpdate" form:"autoUpdate"`
AutoDelete bool `json:"autoDelete" form:"autoDelete"`
InboundIds string `json:"inboundIds" form:"inboundIds"`
}
89 changes: 71 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,26 +1,79 @@
module x-ui

go 1.16
go 1.22.2

require (
github.com/BurntSushi/toml v0.3.1
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect
github.com/Workiva/go-datastructures v1.0.53
github.com/gin-contrib/sessions v0.0.3
github.com/gin-gonic/gin v1.7.1
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/BurntSushi/toml v1.3.2
github.com/Workiva/go-datastructures v1.1.3
github.com/gin-contrib/sessions v1.0.0
github.com/gin-gonic/gin v1.9.1
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1
github.com/nicksnyder/go-i18n/v2 v2.1.2
github.com/nicksnyder/go-i18n/v2 v2.4.0
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
github.com/robfig/cron/v3 v3.0.1
github.com/shirou/gopsutil v3.21.3+incompatible
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/xtls/xray-core v1.4.2
go.uber.org/atomic v1.7.0
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744 // indirect
golang.org/x/text v0.3.6
google.golang.org/grpc v1.38.0
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/driver/sqlite v1.1.4
gorm.io/gorm v1.21.9
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/xtls/xray-core v1.8.10
go.uber.org/atomic v1.11.0
golang.org/x/text v0.14.0
google.golang.org/grpc v1.63.2
gorm.io/driver/sqlite v1.5.5
gorm.io/gorm v1.25.9
)

require (
github.com/dlclark/regexp2 v1.7.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/glebarez/go-sqlite v1.21.2 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
gopkg.in/sourcemap.v1 v1.0.5 // indirect
modernc.org/libc v1.22.5 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect
modernc.org/sqlite v1.23.1 // indirect
)

require (
github.com/bytedance/sonic v1.11.3 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/dop251/goja v0.0.0-20240220182346-e401ed450204
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/glebarez/sqlite v1.11.0
github.com/go-ole/go-ole v1.2.6 // 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.19.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gorilla/context v1.1.2 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/gorilla/sessions v1.2.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
github.com/pires/go-proxyproto v0.7.0 // indirect
github.com/robertkrimen/otto v0.4.0
github.com/sagernet/sing v0.3.8 // indirect
github.com/tklauser/go-sysconf v0.3.13 // indirect
github.com/tklauser/numcpus v0.7.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/arch v0.7.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240308144416-29370a3891b7 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading