From 7412bf17a927df4715b65962de5f683dade83395 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Tue, 11 Apr 2023 15:41:04 +0330 Subject: [PATCH] bug fix Co-Authored-By: Alireza Ahmadi --- web/assets/js/model/xray.js | 6 +-- web/controller/server.go | 25 ++++++++++++ web/html/xui/inbound_info_modal.html | 2 +- web/html/xui/index.html | 58 +++++++++++++++++++--------- web/service/inbound.go | 22 ++++++----- web/service/server.go | 41 ++++++++++++++++++++ 6 files changed, 121 insertions(+), 33 deletions(-) diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index c757f47f..f0ea1efd 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -1636,7 +1636,7 @@ Inbound.VLESSSettings = class extends Inbound.Settings { toJson() { return { clients: Inbound.VLESSSettings.toJsonArray(this.vlesses), - decryption: this.decryption, + decryption: 'none', fallbacks: Inbound.VLESSSettings.toJsonArray(this.fallbacks), }; } @@ -1696,7 +1696,7 @@ Inbound.VLESSSettings.VLESS = class extends XrayCommonClass { } }; Inbound.VLESSSettings.Fallback = class extends XrayCommonClass { - constructor(name="", alpn=[], path='', dest='', xver=0) { + constructor(name="", alpn='', path='', dest='', xver=0) { super(); this.name = name; this.alpn = alpn; @@ -1835,7 +1835,7 @@ Inbound.TrojanSettings.Trojan = class extends XrayCommonClass { }; Inbound.TrojanSettings.Fallback = class extends XrayCommonClass { - constructor(name="", alpn=[], path='', dest='', xver=0) { + constructor(name="", alpn='', path='', dest='', xver=0) { super(); this.name = name; this.alpn = alpn; diff --git a/web/controller/server.go b/web/controller/server.go index 43a1fadc..c5a3965b 100644 --- a/web/controller/server.go +++ b/web/controller/server.go @@ -39,6 +39,8 @@ func (a *ServerController) initRouter(g *gin.RouterGroup) { g.POST("/restartXrayService", a.restartXrayService) g.POST("/installXray/:version", a.installXray) g.POST("/logs/:count", a.getLogs) + g.POST("/getConfigJson", a.getConfigJson) + g.GET("/getDb", a.getDb) } func (a *ServerController) refreshStatus() { @@ -117,3 +119,26 @@ func (a *ServerController) getLogs(c *gin.Context) { } jsonObj(c, logs, nil) } + +func (a *ServerController) getConfigJson(c *gin.Context) { + configJson, err := a.serverService.GetConfigJson() + if err != nil { + jsonMsg(c, I18n(c, "getLogs"), err) + return + } + jsonObj(c, configJson, nil) +} + +func (a *ServerController) getDb(c *gin.Context) { + db, err := a.serverService.GetDb() + if err != nil { + jsonMsg(c, I18n(c, "getLogs"), err) + return + } + // Set the headers for the response + c.Header("Content-Type", "application/octet-stream") + c.Header("Content-Disposition", "attachment; filename=xui.db") + + // Write the file contents to the response + c.Writer.Write(db) +} diff --git a/web/html/xui/inbound_info_modal.html b/web/html/xui/inbound_info_modal.html index 1ba15b08..1b05a12c 100644 --- a/web/html/xui/inbound_info_modal.html +++ b/web/html/xui/inbound_info_modal.html @@ -240,7 +240,7 @@ return infoModal.dbInbound.isEnable; }, get subBase() { - return window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port:"") + "/sub/"; + return window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port:"") + basePath + "sub/"; }, get tgBase() { return "https://t.me/" diff --git a/web/html/xui/index.html b/web/html/xui/index.html index 5a80989c..320422e3 100644 --- a/web/html/xui/index.html +++ b/web/html/xui/index.html @@ -76,18 +76,9 @@ - {{ i18n "pages.index.xrayStatus" }}: - [[ status.xray.state ]] - - - - - [[ status.xray.version ]] - {{ i18n "pages.index.stopXray" }} - {{ i18n "pages.index.restartXray" }} - {{ i18n "pages.index.xraySwitch" }} + 3x-ui: v{{ .cur_ver }} + Xray: v[[ status.xray.version ]] + Telegram: @panel3xui @@ -102,6 +93,29 @@ + + + {{ i18n "pages.index.xrayStatus" }}: + [[ status.xray.state ]] + + + + + {{ i18n "pages.index.stopXray" }} + {{ i18n "pages.index.restartXray" }} + {{ i18n "pages.index.xraySwitch" }} + + + + + {{ i18n "menu.link" }}: + Log Reports + Config + Backup + + {{ i18n "pages.index.systemLoad" }}: [[ status.loads[0] ]] | [[ status.loads[1] ]] | [[ status.loads[2] ]] @@ -169,13 +183,6 @@ - - - - 3x-ui: v{{ .cur_ver }} - Telegram - Log Reports - @@ -226,6 +233,7 @@ {{template "js" .}} +{{template "textModal"}}