From 9fba92d879767394535f70ba83f0a58d6b063a7d Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Fri, 26 Jan 2024 22:07:15 +0330 Subject: [PATCH] v2.1.2 revert #1650 #1661 #1664 #1670 made panel full of bug --- .github/workflows/docker.yml | 2 +- README.md | 4 +- config/version | 2 +- web/assets/js/util/utils.js | 35 ------ web/controller/inbound.go | 111 +++--------------- web/html/common/qrcode_modal.html | 17 +-- web/html/xui/client_modal.html | 154 +++---------------------- web/html/xui/form/client.html | 16 +-- web/html/xui/inbound_modal.html | 4 - web/html/xui/inbounds.html | 82 +++---------- web/translation/translate.en_US.toml | 3 - web/translation/translate.es_ES.toml | 3 - web/translation/translate.fa_IR.toml | 3 - web/translation/translate.ru_RU.toml | 3 - web/translation/translate.vi_VN.toml | 3 - web/translation/translate.zh_Hans.toml | 3 - 16 files changed, 57 insertions(+), 388 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 6afe8618..1115de37 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -36,6 +36,6 @@ jobs: with: context: . push: ${{ github.event_name != 'pull_request' }} - platforms: linux/amd64, linux/arm64/v8, linux/arm/v7, linux/arm/v6, linux/386, linux/arm/v5 + platforms: linux/amd64, linux/arm64/v8, linux/arm/v7, linux/arm/v6, linux/386 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/README.md b/README.md index 6b0beab7..389d6d1d 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,10 @@ bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install. ## Install Custom Version -To install your desired version, add the version to the end of the installation command. e.g., ver `v2.1.1`: +To install your desired version, add the version to the end of the installation command. e.g., ver `v2.1.2`: ``` -bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) v2.1.1 +bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) v2.1.2 ``` ## Manual Install & Upgrade diff --git a/config/version b/config/version index 7c327287..8f9174b4 100644 --- a/config/version +++ b/config/version @@ -1 +1 @@ -2.1.1 \ No newline at end of file +2.1.2 \ No newline at end of file diff --git a/web/assets/js/util/utils.js b/web/assets/js/util/utils.js index 48ff237d..61b322bd 100644 --- a/web/assets/js/util/utils.js +++ b/web/assets/js/util/utils.js @@ -83,41 +83,6 @@ class HttpUtil { } return msg; } - - static async jsonPost(url, data) { - let msg; - try { - const requestOptions = { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(data), - }; - const resp = await fetch(url, requestOptions); - const response = await resp.json(); - - msg = this._respToMsg({data : response}); - } catch (e) { - msg = new Msg(false, e.toString()); - } - this._handleMsg(msg); - return msg; - } - - static async postWithModalJson(url, data, modal) { - if (modal) { - modal.loading(true); - } - const msg = await this.jsonPost(url, data); - if (modal) { - modal.loading(false); - if (msg instanceof Msg && msg.success) { - modal.close(); - } - } - return msg; - } } class PromiseUtil { diff --git a/web/controller/inbound.go b/web/controller/inbound.go index 0aa2e2df..86da9813 100644 --- a/web/controller/inbound.go +++ b/web/controller/inbound.go @@ -1,7 +1,6 @@ package controller import ( - "errors" "encoding/json" "fmt" "strconv" @@ -33,9 +32,7 @@ func (a *InboundController) initRouter(g *gin.RouterGroup) { g.POST("/clientIps/:email", a.getClientIps) g.POST("/clearClientIps/:email", a.clearClientIps) g.POST("/addClient", a.addInboundClient) - g.POST("/addGroupClient", a.addGroupInboundClient) g.POST("/:id/delClient/:clientId", a.delInboundClient) - g.POST("/updateClients", a.updateGroupInboundClient) g.POST("/updateClient/:clientId", a.updateInboundClient) g.POST("/:id/resetClientTraffic/:email", a.resetClientTraffic) g.POST("/resetAllTraffics", a.resetAllTraffics) @@ -163,51 +160,23 @@ func (a *InboundController) clearClientIps(c *gin.Context) { func (a *InboundController) addInboundClient(c *gin.Context) { data := &model.Inbound{} - err := c.ShouldBind(data) - if err != nil { - jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err) - return - } + err := c.ShouldBind(data) + if err != nil { + jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err) + return + } - needRestart := true - - needRestart, err = a.inboundService.AddInboundClient(data) - if err != nil { - jsonMsg(c, "Something went wrong!", err) - return - } - jsonMsg(c, "Client(s) added", nil) - if err == nil && needRestart { - a.xrayService.SetToNeedRestart() - } -} - -func (a *InboundController) addGroupInboundClient(c *gin.Context) { - var requestData []model.Inbound - - err := c.ShouldBindJSON(&requestData) - - if err != nil { - jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err) - return - } - - needRestart := true - - for _, data := range requestData { - - needRestart, err = a.inboundService.AddInboundClient(&data) - if err != nil { - jsonMsg(c, "Something went wrong!", err) - return - } - } - - jsonMsg(c, "Client(s) added", nil) - if err == nil && needRestart { - a.xrayService.SetToNeedRestart() - } + needRestart := true + needRestart, err = a.inboundService.AddInboundClient(data) + if err != nil { + jsonMsg(c, "Something went wrong!", err) + return + } + jsonMsg(c, "Client(s) added", nil) + if err == nil && needRestart { + a.xrayService.SetToNeedRestart() + } } func (a *InboundController) delInboundClient(c *gin.Context) { @@ -254,56 +223,6 @@ func (a *InboundController) updateInboundClient(c *gin.Context) { } } -func (a *InboundController) updateGroupInboundClient(c *gin.Context) { - var requestData []map[string]interface{} - - if err := c.ShouldBindJSON(&requestData); err != nil { - jsonMsg(c, I18nWeb(c, "pages.inbounds.update"), err) - return - } - - needRestart := false - - for _, item := range requestData { - - inboundMap, ok := item["inbound"].(map[string]interface{}) - if !ok { - jsonMsg(c, "Something went wrong!", errors.New("Failed to convert 'inbound' to map")) - return - } - - clientId, ok := item["clientId"].(string) - if !ok { - jsonMsg(c, "Something went wrong!", errors.New("Failed to convert 'clientId' to string")) - return - } - - inboundJSON, err := json.Marshal(inboundMap) - if err != nil { - jsonMsg(c, "Something went wrong!", err) - return - } - - var inboundModel model.Inbound - if err := json.Unmarshal(inboundJSON, &inboundModel); err != nil { - jsonMsg(c, "Something went wrong!", err) - return - } - - if restart, err := a.inboundService.UpdateInboundClient(&inboundModel, clientId); err != nil { - jsonMsg(c, "Something went wrong!", err) - return - } else { - needRestart = needRestart || restart - } - } - - jsonMsg(c, "Client updated", nil) - if needRestart { - a.xrayService.SetToNeedRestart() - } -} - func (a *InboundController) resetClientTraffic(c *gin.Context) { id, err := strconv.Atoi(c.Param("id")) if err != nil { diff --git a/web/html/common/qrcode_modal.html b/web/html/common/qrcode_modal.html index 31b3450c..3c4fd929 100644 --- a/web/html/common/qrcode_modal.html +++ b/web/html/common/qrcode_modal.html @@ -11,12 +11,10 @@ Subscription
- {{ i18n "pages.inbounds.client" }} - @@ -377,7 +373,7 @@

[[ clientEmail ]]

[[ clientCount[dbInbound.id].online.length ]] - + @@ -744,9 +740,6 @@ case "delDepletedClients": this.delDepletedClients(-1) break; - case "addGroupClient": - this.openGroupAddClient() - break; } }, clickAction(action, dbInbound) { @@ -890,20 +883,6 @@ await this.submit(`/panel/inbound/update/${dbInbound.id}`, data, inModal); }, - openGroupAddClient() { - clientModal.show({ - title: '{{ i18n "pages.client.groupAdd"}}', - okText: '{{ i18n "pages.client.submitAdd"}}', - dbInbounds: this.dbInbounds, - confirm: async (clients, dbInboundIds) => { - clientModal.loading(); - await this.addGroupClient(clients, dbInboundIds); - clientModal.close(); - await this.showQrcode(dbInboundIds[0],clients[0], true) - }, - isEdit: false - }); - }, openAddClient(dbInboundId) { dbInbound = this.dbInbounds.find(row => row.id === dbInboundId); clientModal.show({ @@ -914,7 +893,6 @@ clientModal.loading(); await this.addClient(clients, dbInboundId); clientModal.close(); - await this.showQrcode(dbInboundId,clients) }, isEdit: false }); @@ -939,7 +917,6 @@ clientModal.show({ title: '{{ i18n "pages.client.edit"}}', okText: '{{ i18n "pages.client.submitEdit"}}', - dbInbounds: this.dbInbounds, dbInbound: dbInbound, index: index, confirm: async (client, dbInboundId, clientId) => { @@ -963,41 +940,14 @@ id: dbInboundId, settings: '{"clients": [' + clients.toString() + ']}', }; - - await this.submit(`/panel/inbound/addClient`, data) - }, - - async addGroupClient(clients, dbInboundIds) { - const data = [] - dbInboundIds.forEach((dbInboundId, index) => { - data.push({ - id: dbInboundId, - settings: '{"clients": [' + clients[index].toString() + ']}', - }) - }) - - await this.submit(`/panel/inbound/addGroupClient`, data, true) + await this.submit(`/panel/inbound/addClient`, data); }, async updateClient(client, dbInboundId, clientId) { - if (Array.isArray(client) && Array.isArray(dbInboundId) && Array.isArray(clientId)){ - const data = [] - client.forEach((client, index) => { - data.push({ - clientId: clientId[index], - inbound: { - id: dbInboundId[index], - settings: '{"clients": [' + client.toString() + ']}', - } - }) - }) - await this.submit(`/panel/inbound/updateClients`, data, true); - }else{ - const data = { - id: dbInboundId, - settings: '{"clients": [' + client.toString() + ']}', - }; - await this.submit(`/panel/inbound/updateClient/${clientId}`, data); - } + const data = { + id: dbInboundId, + settings: '{"clients": [' + client.toString() + ']}', + }; + await this.submit(`/panel/inbound/updateClient/${clientId}`, data); }, resetTraffic(dbInboundId) { dbInbound = this.dbInbounds.find(row => row.id === dbInboundId); @@ -1051,8 +1001,8 @@ checkFallback(dbInbound) { newDbInbound = new DBInbound(dbInbound); if (dbInbound.listen.startsWith("@")){ - rootInbound = this.inbounds.find((i) => - i.isTcp && + rootInbound = this.inbounds.find((i) => + i.isTcp && ['trojan','vless'].includes(i.protocol) && i.settings.fallbacks.find(f => f.dest === dbInbound.listen) ); @@ -1068,10 +1018,10 @@ } return newDbInbound; }, - showQrcode(dbInboundId, client, isJustSub = false) { + showQrcode(dbInboundId, client) { dbInbound = this.dbInbounds.find(row => row.id === dbInboundId); newDbInbound = this.checkFallback(dbInbound); - qrModal.show('{{ i18n "qrCode"}}', newDbInbound, client, isJustSub); + qrModal.show('{{ i18n "qrCode"}}', newDbInbound, client); }, showInfo(dbInboundId, client) { dbInbound = this.dbInbounds.find(row => row.id === dbInboundId); @@ -1100,8 +1050,8 @@ await this.updateClient(clients[index], dbInboundId, clientId); this.loading(false); }, - async submit(url, data, isJson = false) { - const msg = isJson ? await HttpUtil.postWithModalJson(url, data) : await HttpUtil.postWithModal(url, data); + async submit(url, data) { + const msg = await HttpUtil.postWithModal(url, data); if (msg.success) { await this.getDBInbounds(); } @@ -1243,7 +1193,7 @@ value: '', okText: '{{ i18n "pages.inbounds.import" }}', confirm: async (dbInboundText) => { - await this.submit('/panel/inbound/import', {data: dbInboundText}); + await this.submit('/panel/inbound/import', {data: dbInboundText}, promptModal); promptModal.close(); }, }); diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index 0b7ac5b2..7e0f26c5 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -181,12 +181,9 @@ "exportInbound" = "Export Inbound" "import" = "Import" "importInbound" = "Import an Inbound" -"isGroupEdit" = "Group editing" -"isGroupEditDesc" = "All clients with the same subscription are edited" [pages.client] "add" = "Add Client" -"groupAdd" = "Add subscription user" "edit" = "Edit Client" "submitAdd" = "Add Client" "submitEdit" = "Save Changes" diff --git a/web/translation/translate.es_ES.toml b/web/translation/translate.es_ES.toml index 926325cf..6c817a30 100644 --- a/web/translation/translate.es_ES.toml +++ b/web/translation/translate.es_ES.toml @@ -181,12 +181,9 @@ "exportInbound" = "Exportación entrante" "import" = "Importar" "importInbound" = "Importar un entrante" -"isGroupEdit" = "Edición de grupo" -"isGroupEditDesc" = "Se editan todos los usuarios con la misma suscripción" [pages.client] "add" = "Agregar Cliente" -"groupAdd" = "Agregar usuario de suscripción" "edit" = "Editar Cliente" "submitAdd" = "Agregar Cliente" "submitEdit" = "Guardar Cambios" diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml index 17e6facc..11b66788 100644 --- a/web/translation/translate.fa_IR.toml +++ b/web/translation/translate.fa_IR.toml @@ -181,12 +181,9 @@ "exportInbound" = "استخراج ورودی" "import" = "افزودن" "importInbound" = "افزودن یک ورودی" -"isGroupEdit" = "ویرایش گروهی" -"isGroupEditDesc" = "تمامی کاربران با سابسکریپشن یکسان ویرایش می‌شوند" [pages.client] "add" = "کاربر جدید" -"groupAdd" = "کاربر جدید سابسکریپشن" "edit" = "ویرایش کاربر" "submitAdd" = "اضافه کردن" "submitEdit" = "ذخیره تغییرات" diff --git a/web/translation/translate.ru_RU.toml b/web/translation/translate.ru_RU.toml index c567f38b..2e663e4c 100644 --- a/web/translation/translate.ru_RU.toml +++ b/web/translation/translate.ru_RU.toml @@ -181,12 +181,9 @@ "exportInbound" = "Экспорт входящих" "import" = "Импортировать" "importInbound" = "Импортировать входящее сообщение" -"isGroupEdit" = "Редактирование группы" -"isGroupEditDesc" = "Редактируются все пользователи с одной подпиской" [pages.client] "add" = "Добавить пользователя" -"groupAdd" = "Добавить пользователя подписки" "edit" = "Редактировать пользователя" "submitAdd" = "Добавить пользователя" "submitEdit" = "Сохранить изменения" diff --git a/web/translation/translate.vi_VN.toml b/web/translation/translate.vi_VN.toml index 5876a5b4..4c40adca 100644 --- a/web/translation/translate.vi_VN.toml +++ b/web/translation/translate.vi_VN.toml @@ -181,12 +181,9 @@ "exportInbound" = "Xuất nhập khẩu" "import" = "Nhập" "importInbound" = "Nhập inbound" -"isGroupEdit" = "Chỉnh sửa nhóm" -"isGroupEditDesc" = "Tất cả người dùng có cùng đăng ký đều được chỉnh sửa" [pages.client] "add" = "Thêm người dùng" -"groupAdd" = "Thêm người dùng đăng ký" "edit" = "Chỉnh sửa người dùng" "submitAdd" = "Thêm" "submitEdit" = "Lưu thay đổi" diff --git a/web/translation/translate.zh_Hans.toml b/web/translation/translate.zh_Hans.toml index 29dc8f4c..a8cd3aff 100644 --- a/web/translation/translate.zh_Hans.toml +++ b/web/translation/translate.zh_Hans.toml @@ -181,12 +181,9 @@ "exportInbound" = "出口 入境" "import"="导入" "importInbound" = "导入入站" -"isGroupEdit" = "分组编辑" -"isGroupEditDesc" = "编辑具有相同订阅的所有用户" [pages.client] "add" = "添加客户端" -"groupAdd" = "添加订阅用户" "edit" = "编辑客户端" "submitAdd" = "添加客户端" "submitEdit" = "保存修改"