mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-03-19 09:05:49 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c047cf124 | ||
|
|
c6b59f1ee3 | ||
|
|
b40759fe18 | ||
|
|
e6f08517a3 | ||
|
|
293787f867 | ||
|
|
54bf24f662 | ||
|
|
b4727cc5f8 | ||
|
|
b4fc5a7ab8 | ||
|
|
d0e53231fe | ||
|
|
cce4b0a449 | ||
|
|
ff90e2a02e | ||
|
|
c575425292 | ||
|
|
63f71e527c | ||
|
|
5be9131078 |
52
.github/workflows/release.yml
vendored
52
.github/workflows/release.yml
vendored
@@ -1,12 +1,16 @@
|
|||||||
name: Release 3X-ui
|
name: Release X-ui
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linuxamd64build:
|
linuxamd64build:
|
||||||
name: build x-ui amd64 version
|
name: build x-ui amd64 version
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.5.0
|
- uses: actions/checkout@v3.5.1
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v4.0.0
|
uses: actions/setup-go@v4.0.0
|
||||||
with:
|
with:
|
||||||
@@ -42,3 +46,45 @@ jobs:
|
|||||||
asset_name: x-ui-linux-amd64.tar.gz
|
asset_name: x-ui-linux-amd64.tar.gz
|
||||||
prerelease: true
|
prerelease: true
|
||||||
overwrite: true
|
overwrite: true
|
||||||
|
linuxarm64build:
|
||||||
|
name: build x-ui arm64 version
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3.5.1
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v4.0.0
|
||||||
|
with:
|
||||||
|
go-version: 'stable'
|
||||||
|
- name: build linux arm64 version
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt install gcc-aarch64-linux-gnu
|
||||||
|
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build -o xui-release -v main.go
|
||||||
|
mkdir x-ui
|
||||||
|
cp xui-release x-ui/xui-release
|
||||||
|
cp x-ui.service x-ui/x-ui.service
|
||||||
|
cp x-ui.sh x-ui/x-ui.sh
|
||||||
|
cd x-ui
|
||||||
|
mv xui-release x-ui
|
||||||
|
mkdir bin
|
||||||
|
cd bin
|
||||||
|
wget https://github.com/mhsanaei/xray-core/releases/latest/download/Xray-linux-arm64-v8a.zip
|
||||||
|
unzip Xray-linux-arm64-v8a.zip
|
||||||
|
rm -f Xray-linux-arm64-v8a.zip geoip.dat geosite.dat
|
||||||
|
wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
|
||||||
|
wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
|
||||||
|
wget https://github.com/bootmortis/iran-hosted-domains/releases/latest/download/iran.dat
|
||||||
|
mv xray xray-linux-arm64
|
||||||
|
cd ..
|
||||||
|
cd ..
|
||||||
|
- name: package
|
||||||
|
run: tar -zcvf x-ui-linux-arm64.tar.gz x-ui
|
||||||
|
- name: upload
|
||||||
|
uses: svenstaro/upload-release-action@2.5.0
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
tag: ${{ github.ref }}
|
||||||
|
file: x-ui-linux-arm64.tar.gz
|
||||||
|
asset_name: x-ui-linux-arm64.tar.gz
|
||||||
|
prerelease: true
|
||||||
|
overwrite: true
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.2.2
|
1.2.3
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ func (a *ServerController) getDb(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
// Set the headers for the response
|
// Set the headers for the response
|
||||||
c.Header("Content-Type", "application/octet-stream")
|
c.Header("Content-Type", "application/octet-stream")
|
||||||
c.Header("Content-Disposition", "attachment; filename=xui.db")
|
c.Header("Content-Disposition", "attachment; filename=x-ui.db")
|
||||||
|
|
||||||
// Write the file contents to the response
|
// Write the file contents to the response
|
||||||
c.Writer.Write(db)
|
c.Writer.Write(db)
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ func (s *InboundService) adjustTraffics(traffics []*xray.ClientTraffic) (full_tr
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for traffic_index, traffic := range traffics {
|
for _, traffic := range traffics {
|
||||||
inbound := &model.Inbound{}
|
inbound := &model.Inbound{}
|
||||||
client_traffic := &xray.ClientTraffic{}
|
client_traffic := &xray.ClientTraffic{}
|
||||||
err := db.Model(xray.ClientTraffic{}).Where("email = ?", traffic.Email).First(client_traffic).Error
|
err := db.Model(xray.ClientTraffic{}).Where("email = ?", traffic.Email).First(client_traffic).Error
|
||||||
@@ -492,9 +492,9 @@ func (s *InboundService) adjustTraffics(traffics []*xray.ClientTraffic) (full_tr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
traffics[traffic_index] = client_traffic
|
full_traffics = append(full_traffics, client_traffic)
|
||||||
}
|
}
|
||||||
return traffics, nil
|
return full_traffics, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *InboundService) DisableInvalidInbounds() (int64, error) {
|
func (s *InboundService) DisableInvalidInbounds() (int64, error) {
|
||||||
@@ -507,6 +507,17 @@ func (s *InboundService) DisableInvalidInbounds() (int64, error) {
|
|||||||
count := result.RowsAffected
|
count := result.RowsAffected
|
||||||
return count, err
|
return count, err
|
||||||
}
|
}
|
||||||
|
func (s *InboundService) RemoveOrphanedTraffics() {
|
||||||
|
db := database.GetDB()
|
||||||
|
db.Exec(`
|
||||||
|
DELETE FROM client_traffics
|
||||||
|
WHERE email NOT IN (
|
||||||
|
SELECT JSON_EXTRACT(client.value, '$.email')
|
||||||
|
FROM inbounds,
|
||||||
|
JSON_EACH(JSON_EXTRACT(inbounds.settings, '$.clients')) AS client
|
||||||
|
)
|
||||||
|
`)
|
||||||
|
}
|
||||||
func (s *InboundService) DisableInvalidClients() (int64, error) {
|
func (s *InboundService) DisableInvalidClients() (int64, error) {
|
||||||
db := database.GetDB()
|
db := database.GetDB()
|
||||||
now := time.Now().Unix() * 1000
|
now := time.Now().Unix() * 1000
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.inboundService.DisableInvalidClients()
|
s.inboundService.DisableInvalidClients()
|
||||||
|
s.inboundService.RemoveOrphanedTraffics()
|
||||||
|
|
||||||
inbounds, err := s.inboundService.GetAllInbounds()
|
inbounds, err := s.inboundService.GetAllInbounds()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
8
x-ui.sh
8
x-ui.sh
@@ -726,19 +726,19 @@ run_speedtest() {
|
|||||||
# If not installed, install it
|
# If not installed, install it
|
||||||
if command -v dnf &> /dev/null; then
|
if command -v dnf &> /dev/null; then
|
||||||
sudo dnf install -y curl
|
sudo dnf install -y curl
|
||||||
curl -s https://install.speedtest.net/app/cli/install.rpm.sh | sudo bash
|
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.rpm.sh | sudo bash
|
||||||
sudo dnf install -y speedtest
|
sudo dnf install -y speedtest
|
||||||
elif command -v yum &> /dev/null; then
|
elif command -v yum &> /dev/null; then
|
||||||
sudo yum install -y curl
|
sudo yum install -y curl
|
||||||
curl -s https://install.speedtest.net/app/cli/install.rpm.sh | sudo bash
|
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.rpm.sh | sudo bash
|
||||||
sudo yum install -y speedtest
|
sudo yum install -y speedtest
|
||||||
elif command -v apt-get &> /dev/null; then
|
elif command -v apt-get &> /dev/null; then
|
||||||
sudo apt-get update && sudo apt-get install -y curl
|
sudo apt-get update && sudo apt-get install -y curl
|
||||||
curl -s https://install.speedtest.net/app/cli/install.deb.sh | sudo bash
|
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
|
||||||
sudo apt-get install -y speedtest
|
sudo apt-get install -y speedtest
|
||||||
elif command -v apt &> /dev/null; then
|
elif command -v apt &> /dev/null; then
|
||||||
sudo apt update && sudo apt install -y curl
|
sudo apt update && sudo apt install -y curl
|
||||||
curl -s https://install.speedtest.net/app/cli/install.deb.sh | sudo bash
|
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
|
||||||
sudo apt install -y speedtest
|
sudo apt install -y speedtest
|
||||||
else
|
else
|
||||||
echo "Error: Package manager not found. You may need to install Speedtest manually."
|
echo "Error: Package manager not found. You may need to install Speedtest manually."
|
||||||
|
|||||||
Reference in New Issue
Block a user