mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-11 04:36:20 +00:00
hotfix / some fixes
hotfix / XUI_DEBUG, XUI_LOG_LEVEL hotfix / announce hotfix / debug mode (XUI_DEBUG) fix hotfix / tg bot server ipv4 hotfix / check mem usage
This commit is contained in:
parent
7de62efc6b
commit
26abb907a0
5 changed files with 23 additions and 21 deletions
|
@ -7,4 +7,6 @@ XUI_SUB_DOMAIN=""
|
|||
XUI_VLESS_SNI=""
|
||||
#XUI_SUB_PROFILE_TITLE=""
|
||||
#XUI_SUB_SUPPORT_URL=""
|
||||
#XUI_SUB_PROFILE_WEB_PAGE_URL=""
|
||||
#XUI_SUB_PROFILE_WEB_PAGE_URL=""
|
||||
#XUI_DEBUG="false"
|
||||
#XUI_LOG_LEVEL="info"
|
|
@ -34,6 +34,7 @@ services:
|
|||
volumes:
|
||||
- ./db/:/etc/x-ui/
|
||||
- ./db/fail2ban.sqlite3:/var/lib/fail2ban/fail2ban.sqlite3
|
||||
- ./db/announce.txt:/etc/x-ui/announce.txt
|
||||
- ./cert/:/root/cert/
|
||||
- ./logs/xray-access.log:/app/access.log
|
||||
- ./logs/xray-error.log:/app/error.log
|
||||
|
@ -41,7 +42,6 @@ services:
|
|||
- ./logs/3xipl-ap.log:/var/log/3xipl-ap.log
|
||||
- ./logs/3xipl-banned.log:/var/log/3xipl-banned.log
|
||||
- ./logs/fail2ban.log:/var/log/fail2ban.log
|
||||
- ./announce.txt:/etc/x-ui/announce.txt
|
||||
environment:
|
||||
PUID: 1000
|
||||
PGID: 1000
|
||||
|
@ -51,6 +51,8 @@ services:
|
|||
XUI_SUB_PROFILE_TITLE: "${XUI_SUB_PROFILE_TITLE:-}"
|
||||
XUI_SUB_SUPPORT_URL: "${XUI_SUB_SUPPORT_URL:-}"
|
||||
XUI_SUB_PROFILE_WEB_PAGE_URL: "${XUI_SUB_PROFILE_WEB_PAGE_URL:-}"
|
||||
XUI_DEBUG: "${XUI_DEBUG:-false}"
|
||||
XUI_LOG_LEVEL: "${XUI_LOG_LEVEL:-info}"
|
||||
tty: true
|
||||
restart: unless-stopped
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ func (j *CheckMemJob) Run() {
|
|||
} else {
|
||||
currentMem := memInfo.Used
|
||||
totalMem := memInfo.Total
|
||||
percentMem := int(currentMem / totalMem * 100)
|
||||
percentMem := int(float64(currentMem) / float64(totalMem) * 100)
|
||||
|
||||
if percentMem >= int(threshold) && bool(needRestart) == true {
|
||||
msg := j.tgbotService.I18nBot("tgbot.messages.memThreshold", "Threshold=="+strconv.Itoa(threshold))
|
||||
|
|
|
@ -1074,6 +1074,8 @@ func (t *Tgbot) prepareServerUsageInfo() string {
|
|||
info += t.I18nBot("tgbot.messages.xrayVersion", "XrayVersion=="+fmt.Sprint(t.lastStatus.Xray.Version))
|
||||
|
||||
// get ip address
|
||||
var host string
|
||||
host = os.Getenv("XUI_SERVER_IP")
|
||||
netInterfaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
logger.Error("net.Interfaces failed, err: ", err.Error())
|
||||
|
@ -1087,7 +1089,11 @@ func (t *Tgbot) prepareServerUsageInfo() string {
|
|||
for _, address := range addrs {
|
||||
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||
if ipnet.IP.To4() != nil {
|
||||
ipv4 += ipnet.IP.String() + " "
|
||||
if host != "" {
|
||||
ipv4 += host + " "
|
||||
} else {
|
||||
ipv4 += ipnet.IP.String() + " "
|
||||
}
|
||||
} else if ipnet.IP.To16() != nil && !ipnet.IP.IsLinkLocalUnicast() {
|
||||
ipv6 += ipnet.IP.String() + " "
|
||||
}
|
||||
|
|
26
web/web.go
26
web/web.go
|
@ -204,24 +204,12 @@ func (s *Server) initRouter() (*gin.Engine, error) {
|
|||
engine.FuncMap["i18n"] = i18nWebFunc
|
||||
engine.Use(locale.LocalizerMiddleware())
|
||||
|
||||
// set static files and template
|
||||
if config.IsDebug() {
|
||||
// for development
|
||||
files, err := s.getHtmlFiles()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
engine.LoadHTMLFiles(files...)
|
||||
engine.StaticFS(basePath+"assets", http.FS(os.DirFS("web/assets")))
|
||||
} else {
|
||||
// for production
|
||||
template, err := s.getHtmlTemplate(engine.FuncMap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
engine.SetHTMLTemplate(template)
|
||||
engine.StaticFS(basePath+"assets", http.FS(&wrapAssetsFS{FS: assetsFS}))
|
||||
template, err := s.getHtmlTemplate(engine.FuncMap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
engine.SetHTMLTemplate(template)
|
||||
engine.StaticFS(basePath+"assets", http.FS(&wrapAssetsFS{FS: assetsFS}))
|
||||
|
||||
// Apply the redirect middleware (`/xui` to `/panel`)
|
||||
engine.Use(middleware.RedirectMiddleware(basePath))
|
||||
|
@ -289,12 +277,16 @@ func (s *Server) startTask() {
|
|||
cpuThreshold, err := s.settingService.GetTgCpu()
|
||||
if (err == nil) && (cpuThreshold > 0) {
|
||||
s.cron.AddJob("@every 10s", job.NewCheckCpuJob())
|
||||
} else if err != nil {
|
||||
logger.Errorf("Add NewCheckCpuJob error: %s", err)
|
||||
}
|
||||
|
||||
// Check RAM and alarm to TgBot if threshold passes
|
||||
memThreshold, err := s.settingService.GetTgMem()
|
||||
if (err == nil) && (memThreshold > 0) {
|
||||
s.cron.AddJob("@every 10s", job.NewCheckMemJob())
|
||||
} else if err != nil {
|
||||
logger.Errorf("Add NewCheckMemJob error: %s", err)
|
||||
}
|
||||
} else {
|
||||
s.cron.Remove(entry)
|
||||
|
|
Loading…
Reference in a new issue