Skip to content

Commit a92384b

Browse files
committed
add v1
1 parent aa92fb7 commit a92384b

File tree

131 files changed

+70698
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+70698
-1
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.idea
2+
tmp
3+
bin/xray-darwin-arm64
4+
bin/config.json
5+
dist/
6+
xray-ui-*.tar.gz
7+
/xray-ui
8+
/release.sh
9+
.sync*

Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM golang:latest AS builder
2+
WORKDIR /root
3+
COPY . .
4+
RUN go build main.go
5+
6+
7+
FROM debian:11-slim
8+
RUN apt-get update && apt-get install -y --no-install-recommends -y ca-certificates \
9+
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
10+
WORKDIR /root
11+
COPY --from=builder /root/main /root/xray-ui
12+
COPY bin/. /root/bin/.
13+
VOLUME [ "/etc/xray-ui" ]
14+
CMD [ "./xray-ui" ]

README.md

+99-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,99 @@
1-
# xray-ui
1+
本项目基于上游X-UI项目进行略微的功能改动!后续将紧跟上游X-UI版本更新!在此感谢[vaxilu](https://github.com/vaxilu/x-ui)[FranzKafkaYu](https://github.com/FranzKafkaYu/x-ui)及各位为此项目做出贡献
2+
3+
----------------------------------------------------------------------------------------------------------------------------------------------
4+
5+
本脚本显示功能更加人性化!已解决各种新老系统安装失败问题,并会长期更新,欢迎大家提建议!!
6+
7+
更新日志:
8+
9+
2022.7.4 更新上游支持trojan的多类传输协议支持
10+
11+
2022.6.28 更新上游BUG修复
12+
13+
2022.6.22 更新上游BUG修复,加入自动提示脚本版本更新功能,仅支持SSH端输入"x-ui"后提示
14+
15+
2022.6.20 更新上游内容:加入FranzKafkaYu的流量重置功能与全新的shadowsocks 2022协议
16+
17+
2022.6.12 更新内容:设置用户名、密码、端口时(首次安装或者重置),加入默认回车为随机用户名密码及端口功能,彻底告别admin与54321默认设置
18+
19+
2022.5.17 更新内容:同步上游源码,优化双栈VPS安装结束后,双IP(V4+V6)登录信息的显示
20+
21+
2022.5.12 更新内容:加入已安装提示,更新脚本时不必重新输入账户、密码、端口
22+
23+
2022.4.26 更新上游内容:FranzKafkaYu的TG通知功能
24+
25+
2022.4.16 更新内容:首次安装或者后续设置端口时,如端口被占用会自动提示并要求重新设置端口(直到不冲突为止),防止端口冲突引起的安装失败问题
26+
27+
2022.4.14 更新上游内容:加入IBM Linuxone vps的s390x架构支持(存在被封的可能性)
28+
29+
-------------------------------------------------------------------------------------------------------------------------------------------------
30+
31+
32+
开始安装:
33+
34+
![fe1fd31bba775237a97c3481e1273e7](https://user-images.githubusercontent.com/107276912/175456139-4a57d10d-7185-43bb-9fe0-dcbf5286ed89.png)
35+
36+
37+
安装结束:
38+
39+
![228558a9618189f909f3c4a5918be58](https://user-images.githubusercontent.com/107276912/175456155-7a434e09-4d57-4608-a3b5-dc8f0beae8ff.png)
40+
41+
42+
相关信息直接显示:
43+
44+
![c32f62e3d852e7d5861cfe15f7299eb](https://user-images.githubusercontent.com/107276912/175452392-42b614f9-8c8b-451e-95be-ab33a08fbb1f.png)
45+
46+
---------------------------------------------------------------------------------------------------------------------------------------------
47+
48+
### 纯IPV4/纯IPV6的VPS直接运行一键脚本
49+
50+
```
51+
wget -N https://gitlab.com/rwkgyg/x-ui-yg/raw/main/install.sh && bash install.sh
52+
```
53+
54+
--------------------------------------------------------------------------------------------------------------------------------------------------
55+
### 关于TG通知(上游内容)
56+
57+
使用说明:在面板后台设置机器人相关参数
58+
59+
Tg机器人Token
60+
61+
Tg机器人ChatId
62+
63+
#### Tg机器人周期运行时间,采用crontab语法参考语法:
64+
65+
30 * * * * * //每一分的第30s进行通知
66+
67+
@hourly //每小时通知
68+
69+
@daily //每天通知(凌晨零点整)
70+
71+
@every 8h //每8小时通知
72+
73+
@every 30s //每30s通知一次
74+
75+
#### TG通知内容:
76+
77+
节点流量使用
78+
79+
面板登录提醒
80+
81+
节点到期提醒
82+
83+
流量预警提醒
84+
85+
#### TG机器人可输入内容:
86+
87+
/delete port将会删除对应端口的节点
88+
89+
/restart 将会重启xray服务,该命令不会重启xray-ui面板自身
90+
91+
/status 将会获取当前系统状态
92+
93+
/enable port将会开启对应端口的节点
94+
95+
/disable port将会关闭对应端口的节点
96+
97+
/version v1.5.5将会升级xray到1.5.5版本
98+
99+
/help 获取帮助信息

bin/geoip.dat

5 MB
Binary file not shown.

bin/geosite.dat

+11,273
Large diffs are not rendered by default.

bin/xray-linux-amd64

18.3 MB
Binary file not shown.

bin/xray-linux-arm64

17.1 MB
Binary file not shown.

config/config.go

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package config
2+
3+
import (
4+
_ "embed"
5+
"fmt"
6+
"os"
7+
"strings"
8+
)
9+
10+
//go:embed version
11+
var version string
12+
13+
//go:embed name
14+
var name string
15+
16+
type LogLevel string
17+
18+
const (
19+
Debug LogLevel = "debug"
20+
Info LogLevel = "info"
21+
Warn LogLevel = "warn"
22+
Error LogLevel = "error"
23+
)
24+
25+
func GetVersion() string {
26+
return strings.TrimSpace(version)
27+
}
28+
29+
func GetName() string {
30+
return strings.TrimSpace(name)
31+
}
32+
33+
func GetLogLevel() LogLevel {
34+
if IsDebug() {
35+
return Debug
36+
}
37+
logLevel := os.Getenv("XUI_LOG_LEVEL")
38+
if logLevel == "" {
39+
return Info
40+
}
41+
return LogLevel(logLevel)
42+
}
43+
44+
func IsDebug() bool {
45+
return os.Getenv("XUI_DEBUG") == "true"
46+
}
47+
48+
func GetDBPath() string {
49+
return fmt.Sprintf("/etc/%s/%s.db", GetName(), GetName())
50+
}

config/name

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
xray-ui

config/version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.1.1

database/db.go

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package database
2+
3+
import (
4+
"gorm.io/driver/sqlite"
5+
"gorm.io/gorm"
6+
"gorm.io/gorm/logger"
7+
"io/fs"
8+
"os"
9+
"path"
10+
"xray-ui/config"
11+
"xray-ui/database/model"
12+
)
13+
14+
var db *gorm.DB
15+
16+
func initUser() error {
17+
err := db.AutoMigrate(&model.User{})
18+
if err != nil {
19+
return err
20+
}
21+
var count int64
22+
err = db.Model(&model.User{}).Count(&count).Error
23+
if err != nil {
24+
return err
25+
}
26+
if count == 0 {
27+
user := &model.User{
28+
Username: "admin",
29+
Password: "admin",
30+
}
31+
return db.Create(user).Error
32+
}
33+
return nil
34+
}
35+
36+
func initInbound() error {
37+
return db.AutoMigrate(&model.Inbound{})
38+
}
39+
40+
func initSetting() error {
41+
return db.AutoMigrate(&model.Setting{})
42+
}
43+
44+
func InitDB(dbPath string) error {
45+
dir := path.Dir(dbPath)
46+
err := os.MkdirAll(dir, fs.ModeDir)
47+
if err != nil {
48+
return err
49+
}
50+
51+
var gormLogger logger.Interface
52+
53+
if config.IsDebug() {
54+
gormLogger = logger.Default
55+
} else {
56+
gormLogger = logger.Discard
57+
}
58+
59+
c := &gorm.Config{
60+
Logger: gormLogger,
61+
}
62+
db, err = gorm.Open(sqlite.Open(dbPath), c)
63+
if err != nil {
64+
return err
65+
}
66+
67+
err = initUser()
68+
if err != nil {
69+
return err
70+
}
71+
err = initInbound()
72+
if err != nil {
73+
return err
74+
}
75+
err = initSetting()
76+
if err != nil {
77+
return err
78+
}
79+
80+
return nil
81+
}
82+
83+
func GetDB() *gorm.DB {
84+
return db
85+
}
86+
87+
func IsNotFound(err error) bool {
88+
return err == gorm.ErrRecordNotFound
89+
}

database/model/model.go

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package model
2+
3+
import (
4+
"fmt"
5+
"xray-ui/util/json_util"
6+
"xray-ui/xray"
7+
)
8+
9+
type Protocol string
10+
11+
const (
12+
VMess Protocol = "vmess"
13+
VLESS Protocol = "vless"
14+
Dokodemo Protocol = "Dokodemo-door"
15+
Http Protocol = "http"
16+
Trojan Protocol = "trojan"
17+
Shadowsocks Protocol = "shadowsocks"
18+
)
19+
20+
type User struct {
21+
Id int `json:"id" gorm:"primaryKey;autoIncrement"`
22+
Username string `json:"username"`
23+
Password string `json:"password"`
24+
}
25+
26+
type Inbound struct {
27+
Id int `json:"id" form:"id" gorm:"primaryKey;autoIncrement"`
28+
UserId int `json:"-"`
29+
Up int64 `json:"up" form:"up"`
30+
Down int64 `json:"down" form:"down"`
31+
Total int64 `json:"total" form:"total"`
32+
Remark string `json:"remark" form:"remark"`
33+
Enable bool `json:"enable" form:"enable"`
34+
ExpiryTime int64 `json:"expiryTime" form:"expiryTime"`
35+
36+
// config part
37+
Listen string `json:"listen" form:"listen"`
38+
Port int `json:"port" form:"port" gorm:"unique"`
39+
Protocol Protocol `json:"protocol" form:"protocol"`
40+
Settings string `json:"settings" form:"settings"`
41+
StreamSettings string `json:"streamSettings" form:"streamSettings"`
42+
Tag string `json:"tag" form:"tag" gorm:"unique"`
43+
Sniffing string `json:"sniffing" form:"sniffing"`
44+
}
45+
46+
func (i *Inbound) GenXrayInboundConfig() *xray.InboundConfig {
47+
listen := i.Listen
48+
if listen != "" {
49+
listen = fmt.Sprintf("\"%v\"", listen)
50+
}
51+
return &xray.InboundConfig{
52+
Listen: json_util.RawMessage(listen),
53+
Port: i.Port,
54+
Protocol: string(i.Protocol),
55+
Settings: json_util.RawMessage(i.Settings),
56+
StreamSettings: json_util.RawMessage(i.StreamSettings),
57+
Tag: i.Tag,
58+
Sniffing: json_util.RawMessage(i.Sniffing),
59+
}
60+
}
61+
62+
type Setting struct {
63+
Id int `json:"id" form:"id" gorm:"primaryKey;autoIncrement"`
64+
Key string `json:"key" form:"key"`
65+
Value string `json:"value" form:"value"`
66+
}

go.mod

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
module xray-ui
2+
3+
go 1.18
4+
5+
require (
6+
github.com/BurntSushi/toml v1.1.0
7+
github.com/Workiva/go-datastructures v1.0.53
8+
github.com/gin-contrib/sessions v0.0.5
9+
github.com/gin-gonic/gin v1.8.1
10+
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1
11+
github.com/nicksnyder/go-i18n/v2 v2.2.0
12+
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
13+
github.com/robfig/cron/v3 v3.0.1
14+
github.com/shirou/gopsutil v3.21.11+incompatible
15+
github.com/xtls/xray-core v1.6.0
16+
go.uber.org/atomic v1.9.0
17+
golang.org/x/text v0.3.7
18+
google.golang.org/grpc v1.49.0
19+
gorm.io/driver/sqlite v1.3.5
20+
gorm.io/gorm v1.23.7
21+
)
22+
23+
require (
24+
github.com/gin-contrib/sse v0.1.0 // indirect
25+
github.com/go-ole/go-ole v1.2.6 // indirect
26+
github.com/go-playground/locales v0.14.0 // indirect
27+
github.com/go-playground/universal-translator v0.18.0 // indirect
28+
github.com/go-playground/validator/v10 v10.11.0 // indirect
29+
github.com/goccy/go-json v0.9.8 // indirect
30+
github.com/golang/protobuf v1.5.2 // indirect
31+
github.com/gorilla/context v1.1.1 // indirect
32+
github.com/gorilla/securecookie v1.1.1 // indirect
33+
github.com/gorilla/sessions v1.2.1 // indirect
34+
github.com/jinzhu/inflection v1.0.0 // indirect
35+
github.com/jinzhu/now v1.1.5 // indirect
36+
github.com/json-iterator/go v1.1.12 // indirect
37+
github.com/leodido/go-urn v1.2.1 // indirect
38+
github.com/mattn/go-isatty v0.0.14 // indirect
39+
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
40+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
41+
github.com/modern-go/reflect2 v1.0.2 // indirect
42+
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
43+
github.com/pires/go-proxyproto v0.6.2 // indirect
44+
github.com/tklauser/go-sysconf v0.3.10 // indirect
45+
github.com/tklauser/numcpus v0.5.0 // indirect
46+
github.com/ugorji/go/codec v1.2.7 // indirect
47+
github.com/yusufpapurcu/wmi v1.2.2 // indirect
48+
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
49+
golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect
50+
golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41 // indirect
51+
google.golang.org/genproto v0.0.0-20220916172020-2692e8806bfa // indirect
52+
google.golang.org/protobuf v1.28.1 // indirect
53+
gopkg.in/yaml.v2 v2.4.0 // indirect
54+
)

0 commit comments

Comments
 (0)