Skip to content

Commit e240cb8

Browse files
committed
add github worklows for android (termux)
1 parent 9c1be8c commit e240cb8

File tree

13 files changed

+274
-139
lines changed

13 files changed

+274
-139
lines changed

.github/workflows/android_termux.yml

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: Release X-ui for Android (Termux)
2+
on:
3+
push:
4+
tags:
5+
- 0.*
6+
workflow_dispatch:
7+
inputs:
8+
ssh:
9+
description: 'SSH connection to Actions'
10+
required: false
11+
default: 'false'
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
upload_url: ${{ steps.create_release.outputs.upload_url }}
18+
steps:
19+
- name: Create Release
20+
id: create_release
21+
uses: actions/create-release@v1
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GAYHUB_TOKEN }}
24+
with:
25+
tag_name: ${{ github.ref }}
26+
release_name: ${{ github.ref }}
27+
draft: true
28+
prerelease: true
29+
androidbuild:
30+
name: build x-ui android version
31+
needs: release
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v2
35+
- name: Set up Go
36+
uses: actions/setup-go@v2
37+
with:
38+
go-version: 1.18
39+
- name: build android arm64 version
40+
run: |
41+
sudo apt-get update
42+
sudo apt install gcc-aarch64-linux-gnu
43+
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build -o xui-release -v main.go
44+
mkdir x-ui
45+
cp xui-release x-ui/xui-release
46+
# cp x-ui.service x-ui/x-ui.service
47+
# cp x-ui.sh x-ui/x-ui.sh
48+
cd x-ui
49+
mv xui-release x-ui
50+
mkdir bin
51+
cd bin
52+
wget https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-arm64-v8a.zip
53+
unzip Xray-linux-arm64-v8a.zip
54+
rm -f Xray-linux-arm64-v8a.zip geoip.dat geosite.dat
55+
wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
56+
wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
57+
cd ..
58+
cd ..
59+
- name: SSH connection to Actions
60+
uses: P3TERX/[email protected]
61+
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
62+
with:
63+
mode: ngrok
64+
env:
65+
# After sign up on the https://ngrok.com
66+
# You can find this token here: https://dashboard.ngrok.com/auth/your-authtoken
67+
NGROK_TOKEN: ${{ secrets.NGROK_TOKEN }}
68+
69+
# ngrok server region [us, eu, au, ap, sa, jp, in] (optional, default: us)
70+
# You can find this server region here: https://ngrok.com/docs#global-locations
71+
NGROK_REGION: us
72+
73+
# This password you will use when authorizing via SSH
74+
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }}
75+
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
76+
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
77+
- name: package
78+
run: tar -zcvf x-ui-android-arm64.tar.gz x-ui
79+
- name: upload
80+
uses: actions/upload-release-asset@v1
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
with:
84+
upload_url: ${{ needs.release.outputs.upload_url }}
85+
asset_path: x-ui-linux-arm64.tar.gz
86+
asset_name: x-ui-linux-arm64.tar.gz
87+
asset_content_type: application/gzip
88+
89+
name: build x-ui s390x version
90+
needs: release
91+
runs-on: ubuntu-latest
92+
steps:
93+
- uses: actions/checkout@v2
94+
- name: Set up Go
95+
uses: actions/setup-go@v2
96+
with:
97+
go-version: 1.18
98+
- name: build linux s390x version
99+
run: |
100+
sudo apt-get update
101+
sudo apt install gcc-s390x-linux-gnu -y
102+
CGO_ENABLED=1 GOOS=linux GOARCH=s390x CC=s390x-linux-gnu-gcc go build -o xui-release -v main.go
103+
mkdir x-ui
104+
cp xui-release x-ui/xui-release
105+
cp x-ui.service x-ui/x-ui.service
106+
cp x-ui.sh x-ui/x-ui.sh
107+
cd x-ui
108+
mv xui-release x-ui
109+
mkdir bin
110+
cd bin
111+
wget https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-s390x.zip
112+
unzip Xray-linux-s390x.zip
113+
rm -f Xray-linux-s390x.zip geoip.dat geosite.dat
114+
wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
115+
wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
116+
mv xray xray-linux-s390x
117+
cd ..
118+
cd ..
119+
- name: package
120+
run: tar -zcvf x-ui-linux-s390x.tar.gz x-ui
121+
- name: upload
122+
uses: actions/upload-release-asset@v1
123+
env:
124+
GITHUB_TOKEN: ${{ secrets.GAYHUB_TOKEN }}
125+
with:
126+
upload_url: ${{ needs.release.outputs.upload_url }}
127+
asset_path: x-ui-linux-s390x.tar.gz
128+
asset_name: x-ui-linux-s390x.tar.gz
129+
asset_content_type: application/gzip

.vscode/sftp.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "My Server",
3+
"host": "192.168.1.167",
4+
"protocol": "sftp",
5+
"port": 22,
6+
"username": "x",
7+
"password": "kenhtaymay",
8+
"remotePath": "/data/data/com.termux/x-ui",
9+
"uploadOnSave": true,
10+
"downloadOnOpen": true
11+
}

bin/xray-android-arm64

17.1 MB
Binary file not shown.

config/config.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ func GetLogLevel() LogLevel {
4242
}
4343

4444
func IsDebug() bool {
45-
return os.Getenv("XUI_DEBUG") == "true"
45+
// return os.Getenv("XUI_DEBUG") == "true"
46+
return true
4647
}
4748

4849
func GetDBPath() string {
49-
return fmt.Sprintf("/etc/%s/%s.db", GetName(), GetName())
50+
// return fmt.Sprintf("/etc/%s/%s.db", GetName(), GetName())
51+
return fmt.Sprintf("ktm.db")
5052
}

ktm.db

24 KB
Binary file not shown.

ktmx.db

24 KB
Binary file not shown.

main.go

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func runWebServer() {
3737

3838
err := database.InitDB(config.GetDBPath())
3939
if err != nil {
40+
log.Printf(config.GetDBPath())
4041
log.Fatal(err)
4142
}
4243

web/controller/index.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (a *IndexController) index(c *gin.Context) {
3939
c.Redirect(http.StatusTemporaryRedirect, "xui/")
4040
return
4141
}
42-
html(c, "login.html", "登录", nil)
42+
html(c, "login.html", "Kênh Táy Máy [x-ui]", nil)
4343
}
4444

4545
func (a *IndexController) login(c *gin.Context) {

web/controller/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (a *ServerController) initRouter(g *gin.RouterGroup) {
3838
}
3939

4040
func (a *ServerController) refreshStatus() {
41-
a.lastStatus = a.serverService.GetStatus(a.lastStatus)
41+
// a.lastStatus = a.serverService.GetStatus(a.lastStatus)
4242
}
4343

4444
func (a *ServerController) startTask() {

web/job/stats_notify_job.go

+35-39
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ import (
55
"net"
66
"os"
77

8-
"time"
9-
108
"x-ui/logger"
11-
"x-ui/util/common"
129
"x-ui/web/service"
13-
14-
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
10+
// tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
1511
)
1612

1713
type LoginStatus byte
@@ -32,32 +28,32 @@ func NewStatsNotifyJob() *StatsNotifyJob {
3228
return new(StatsNotifyJob)
3329
}
3430

35-
func (j *StatsNotifyJob) SendMsgToTgbot(msg string) {
36-
//Telegram bot basic info
37-
tgBottoken, err := j.settingService.GetTgBotToken()
38-
if err != nil {
39-
logger.Warning("sendMsgToTgbot failed,GetTgBotToken fail:", err)
40-
return
41-
}
42-
tgBotid, err := j.settingService.GetTgBotChatId()
43-
if err != nil {
44-
logger.Warning("sendMsgToTgbot failed,GetTgBotChatId fail:", err)
45-
return
46-
}
31+
// func (j *StatsNotifyJob) SendMsgToTgbot(msg string) {
32+
// //Telegram bot basic info
33+
// tgBottoken, err := j.settingService.GetTgBotToken()
34+
// if err != nil {
35+
// logger.Warning("sendMsgToTgbot failed,GetTgBotToken fail:", err)
36+
// return
37+
// }
38+
// tgBotid, err := j.settingService.GetTgBotChatId()
39+
// if err != nil {
40+
// logger.Warning("sendMsgToTgbot failed,GetTgBotChatId fail:", err)
41+
// return
42+
// }
4743

48-
bot, err := tgbotapi.NewBotAPI(tgBottoken)
49-
if err != nil {
50-
fmt.Println("get tgbot error:", err)
51-
return
52-
}
53-
bot.Debug = true
54-
fmt.Printf("Authorized on account %s", bot.Self.UserName)
55-
info := tgbotapi.NewMessage(int64(tgBotid), msg)
56-
//msg.ReplyToMessageID = int(tgBotid)
57-
bot.Send(info)
58-
}
44+
// bot, err := tgbotapi.NewBotAPI(tgBottoken)
45+
// if err != nil {
46+
// fmt.Println("get tgbot error:", err)
47+
// return
48+
// }
49+
// bot.Debug = true
50+
// fmt.Printf("Authorized on account %s", bot.Self.UserName)
51+
// info := tgbotapi.NewMessage(int64(tgBotid), msg)
52+
// //msg.ReplyToMessageID = int(tgBotid)
53+
// bot.Send(info)
54+
// }
5955

60-
//Here run is a interface method of Job interface
56+
// Here run is a interface method of Job interface
6157
func (j *StatsNotifyJob) Run() {
6258
if !j.xrayService.IsXrayRunning() {
6359
return
@@ -105,15 +101,15 @@ func (j *StatsNotifyJob) Run() {
105101
}
106102
//NOTE:If there no any sessions here,need to notify here
107103
//TODO:分节点推送,自动转化格式
108-
for _, inbound := range inbouds {
109-
info += fmt.Sprintf("节点名称:%s\r\n端口:%d\r\n上行流量↑:%s\r\n下行流量↓:%s\r\n总流量:%s\r\n", inbound.Remark, inbound.Port, common.FormatTraffic(inbound.Up), common.FormatTraffic(inbound.Down), common.FormatTraffic((inbound.Up + inbound.Down)))
110-
if inbound.ExpiryTime == 0 {
111-
info += fmt.Sprintf("到期时间:无限期\r\n \r\n")
112-
} else {
113-
info += fmt.Sprintf("到期时间:%s\r\n \r\n", time.Unix((inbound.ExpiryTime/1000), 0).Format("2006-01-02 15:04:05"))
114-
}
115-
}
116-
j.SendMsgToTgbot(info)
104+
// for _, inbound := range inbouds {
105+
// info += fmt.Sprintf("节点名称:%s\r\n端口:%d\r\n上行流量↑:%s\r\n下行流量↓:%s\r\n总流量:%s\r\n", inbound.Remark, inbound.Port, common.FormatTraffic(inbound.Up), common.FormatTraffic(inbound.Down), common.FormatTraffic((inbound.Up + inbound.Down)))
106+
// if inbound.ExpiryTime == 0 {
107+
// info += fmt.Sprintf("到期时间:无限期\r\n \r\n")
108+
// } else {
109+
// info += fmt.Sprintf("到期时间:%s\r\n \r\n", time.Unix((inbound.ExpiryTime/1000), 0).Format("2006-01-02 15:04:05"))
110+
// }
111+
// }
112+
// j.SendMsgToTgbot(info)
117113
}
118114

119115
func (j *StatsNotifyJob) UserLoginNotify(username string, ip string, time string, status LoginStatus) {
@@ -136,5 +132,5 @@ func (j *StatsNotifyJob) UserLoginNotify(username string, ip string, time string
136132
msg += fmt.Sprintf("时间:%s\r\n", time)
137133
msg += fmt.Sprintf("用户:%s\r\n", username)
138134
msg += fmt.Sprintf("IP:%s\r\n", ip)
139-
j.SendMsgToTgbot(msg)
135+
// j.SendMsgToTgbot(msg)
140136
}

0 commit comments

Comments
 (0)