diff --git a/web/controller/server.go b/web/controller/server.go index 17b25cdc..2d2f741e 100644 --- a/web/controller/server.go +++ b/web/controller/server.go @@ -45,6 +45,7 @@ func (a *ServerController) initRouter(g *gin.RouterGroup) { g.POST("/stopXrayService", a.stopXrayService) g.POST("/restartXrayService", a.restartXrayService) g.POST("/installXray/:version", a.installXray) + g.POST("/updateGeofile", a.updateGeofile) g.POST("/updateGeofile/:fileName", a.updateGeofile) g.POST("/logs/:count", a.getLogs) g.POST("/xraylogs/:count", a.getXrayLogs) diff --git a/web/html/index.html b/web/html/index.html index bc5483b0..d3155edd 100644 --- a/web/html/index.html +++ b/web/html/index.html @@ -383,6 +383,9 @@ +
+ {{ i18n "pages.index.geofilesUpdateAll" }} +
@@ -786,16 +789,22 @@ ${dateTime} }); }, updateGeofile(fileName) { + const isSingleFile = !!fileName; this.$confirm({ title: '{{ i18n "pages.index.geofileUpdateDialog" }}', - content: '{{ i18n "pages.index.geofileUpdateDialogDesc" }}'.replace("#filename#", fileName), + content: isSingleFile + ? '{{ i18n "pages.index.geofileUpdateDialogDesc" }}'.replace("#filename#", fileName) + : '{{ i18n "pages.index.geofilesUpdateDialogDesc" }}', okText: '{{ i18n "confirm"}}', class: themeSwitcher.currentTheme, cancelText: '{{ i18n "cancel"}}', onOk: async () => { versionModal.hide(); this.loading(true, '{{ i18n "pages.index.dontRefresh"}}'); - await HttpUtil.post(`/server/updateGeofile/${fileName}`); + const url = isSingleFile + ? `/server/updateGeofile/${fileName}` + : `/server/updateGeofile`; + await HttpUtil.post(url); this.loading(false); }, }); diff --git a/web/service/server.go b/web/service/server.go index ee13b268..8b1bc0a9 100644 --- a/web/service/server.go +++ b/web/service/server.go @@ -511,7 +511,7 @@ func (s *ServerService) GetXrayLogs( line := strings.TrimSpace(scanner.Text()) if line == "" || strings.Contains(line, "api -> api") { - //skipping empty lines and api calls + //skipping empty lines and api calls continue } @@ -742,27 +742,43 @@ func (s *ServerService) UpdateGeofile(fileName string) error { return nil } - var fileURL string - for _, file := range files { - if file.FileName == fileName { - fileURL = file.URL - break + var errorMessages []string + + if fileName == "" { + for _, file := range files { + destPath := fmt.Sprintf("%s/%s", config.GetBinFolderPath(), file.FileName) + + if err := downloadFile(file.URL, destPath); err != nil { + errorMessages = append(errorMessages, fmt.Sprintf("Error downloading Geofile '%s': %v", file.FileName, err)) + } } - } + } else { + destPath := fmt.Sprintf("%s/%s", config.GetBinFolderPath(), fileName) - if fileURL == "" { - return common.NewErrorf("File '%s' not found in the list of Geofiles", fileName) - } + var fileURL string + for _, file := range files { + if file.FileName == fileName { + fileURL = file.URL + break + } + } - destPath := fmt.Sprintf("%s/%s", config.GetBinFolderPath(), fileName) + if fileURL == "" { + errorMessages = append(errorMessages, fmt.Sprintf("File '%s' not found in the list of Geofiles", fileName)) + } - if err := downloadFile(fileURL, destPath); err != nil { - return common.NewErrorf("Error downloading Geofile '%s': %v", fileName, err) + if err := downloadFile(fileURL, destPath); err != nil { + errorMessages = append(errorMessages, fmt.Sprintf("Error downloading Geofile '%s': %v", fileName, err)) + } } err := s.RestartXrayService() if err != nil { - return common.NewErrorf("Updated Geofile '%s' but Failed to start Xray: %v", fileName, err) + errorMessages = append(errorMessages, fmt.Sprintf("Updated Geofile '%s' but Failed to start Xray: %v", fileName, err)) + } + + if len(errorMessages) > 0 { + return common.NewErrorf("%s", strings.Join(errorMessages, "\r\n")) } return nil diff --git a/web/translation/translate.ar_EG.toml b/web/translation/translate.ar_EG.toml index 3c2fc04f..19d451fa 100644 --- a/web/translation/translate.ar_EG.toml +++ b/web/translation/translate.ar_EG.toml @@ -132,6 +132,8 @@ "xraySwitchVersionPopover" = "تم تحديث Xray بنجاح" "geofileUpdateDialog" = "هل تريد حقًا تحديث ملف الجغرافيا؟" "geofileUpdateDialogDesc" = "سيؤدي هذا إلى تحديث ملف #filename#." +"geofilesUpdateDialogDesc" = "سيؤدي هذا إلى تحديث كافة الملفات." +"geofilesUpdateAll" = "تحديث الكل" "geofileUpdatePopover" = "تم تحديث ملف الجغرافيا بنجاح" "dontRefresh" = "التثبيت شغال، متعملش Refresh للصفحة" "logs" = "السجلات" diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index 4ddef0da..e0ce49aa 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -132,6 +132,8 @@ "xraySwitchVersionPopover" = "Xray updated successfully" "geofileUpdateDialog" = "Do you really want to update the geofile?" "geofileUpdateDialogDesc" = "This will update the #filename# file." +"geofilesUpdateDialogDesc" = "This will update all geofiles." +"geofilesUpdateAll" = "Update all" "geofileUpdatePopover" = "Geofile updated successfully" "dontRefresh" = "Installation is in progress, please do not refresh this page" "logs" = "Logs" diff --git a/web/translation/translate.es_ES.toml b/web/translation/translate.es_ES.toml index 51a5aea8..73cf110b 100644 --- a/web/translation/translate.es_ES.toml +++ b/web/translation/translate.es_ES.toml @@ -132,6 +132,8 @@ "xraySwitchVersionPopover" = "Xray se actualizó correctamente" "geofileUpdateDialog" = "¿Realmente deseas actualizar el geofichero?" "geofileUpdateDialogDesc" = "Esto actualizará el archivo #filename#." +"geofilesUpdateDialogDesc" = "Esto actualizará todos los archivos." +"geofilesUpdateAll" = "Actualizar todo" "geofileUpdatePopover" = "Geofichero actualizado correctamente" "dontRefresh" = "La instalación está en progreso, por favor no actualices esta página." "logs" = "Registros" diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml index 35100f66..8e2b04a2 100644 --- a/web/translation/translate.fa_IR.toml +++ b/web/translation/translate.fa_IR.toml @@ -132,6 +132,8 @@ "xraySwitchVersionPopover" = "Xray با موفقیت به‌روز شد" "geofileUpdateDialog" = "آیا واقعاً می‌خواهید فایل جغرافیایی را به‌روز کنید؟" "geofileUpdateDialogDesc" = "این عمل فایل #filename# را به‌روز می‌کند." +"geofilesUpdateDialogDesc" = "با این کار همه فایل‌ها به‌روزرسانی می‌شوند." +"geofilesUpdateAll" = "همه را به‌روزرسانی کنید" "geofileUpdatePopover" = "فایل جغرافیایی با موفقیت به‌روز شد" "dontRefresh" = "در حال نصب، لطفا صفحه را رفرش نکنید" "logs" = "گزارش‌ها" diff --git a/web/translation/translate.id_ID.toml b/web/translation/translate.id_ID.toml index 21e87dd7..bb30ead9 100644 --- a/web/translation/translate.id_ID.toml +++ b/web/translation/translate.id_ID.toml @@ -132,6 +132,8 @@ "xraySwitchVersionPopover" = "Xray berhasil diperbarui" "geofileUpdateDialog" = "Apakah Anda yakin ingin memperbarui geofile?" "geofileUpdateDialogDesc" = "Ini akan memperbarui file #filename#." +"geofilesUpdateDialogDesc" = "Ini akan memperbarui semua berkas." +"geofilesUpdateAll" = "Perbarui semua" "geofileUpdatePopover" = "Geofile berhasil diperbarui" "dontRefresh" = "Instalasi sedang berlangsung, harap jangan menyegarkan halaman ini" "logs" = "Log" diff --git a/web/translation/translate.ja_JP.toml b/web/translation/translate.ja_JP.toml index 4bc620c6..eed4cc94 100644 --- a/web/translation/translate.ja_JP.toml +++ b/web/translation/translate.ja_JP.toml @@ -132,6 +132,8 @@ "xraySwitchVersionPopover" = "Xrayの更新が成功しました" "geofileUpdateDialog" = "ジオファイルを本当に更新しますか?" "geofileUpdateDialogDesc" = "これにより#filename#ファイルが更新されます。" +"geofilesUpdateDialogDesc" = "これにより、すべてのファイルが更新されます。" +"geofilesUpdateAll" = "すべて更新" "geofileUpdatePopover" = "ジオファイルの更新が成功しました" "dontRefresh" = "インストール中、このページをリロードしないでください" "logs" = "ログ" diff --git a/web/translation/translate.pt_BR.toml b/web/translation/translate.pt_BR.toml index a81f95fb..6f12077d 100644 --- a/web/translation/translate.pt_BR.toml +++ b/web/translation/translate.pt_BR.toml @@ -132,6 +132,8 @@ "xraySwitchVersionPopover" = "Xray atualizado com sucesso" "geofileUpdateDialog" = "Você realmente deseja atualizar o geofile?" "geofileUpdateDialogDesc" = "Isso atualizará o arquivo #filename#." +"geofilesUpdateDialogDesc" = "Isso atualizará todos os arquivos." +"geofilesUpdateAll" = "Atualizar tudo" "geofileUpdatePopover" = "Geofile atualizado com sucesso" "dontRefresh" = "Instalação em andamento, por favor não atualize a página" "logs" = "Logs" diff --git a/web/translation/translate.ru_RU.toml b/web/translation/translate.ru_RU.toml index 114ada89..f9ea047e 100644 --- a/web/translation/translate.ru_RU.toml +++ b/web/translation/translate.ru_RU.toml @@ -132,6 +132,8 @@ "xraySwitchVersionPopover" = "Xray успешно обновлён" "geofileUpdateDialog" = "Вы действительно хотите обновить геофайл?" "geofileUpdateDialogDesc" = "Это обновит файл #filename#." +"geofilesUpdateDialogDesc" = "Это обновит все геофайлы." +"geofilesUpdateAll" = "Обновить все" "geofileUpdatePopover" = "Геофайл успешно обновлён" "dontRefresh" = "Установка в процессе. Не обновляйте страницу" "logs" = "Журнал" diff --git a/web/translation/translate.tr_TR.toml b/web/translation/translate.tr_TR.toml index 319b2a9e..803becd8 100644 --- a/web/translation/translate.tr_TR.toml +++ b/web/translation/translate.tr_TR.toml @@ -132,6 +132,8 @@ "xraySwitchVersionPopover" = "Xray başarıyla güncellendi" "geofileUpdateDialog" = "Geofile'ı gerçekten güncellemek istiyor musunuz?" "geofileUpdateDialogDesc" = "Bu işlem #filename# dosyasını güncelleyecektir." +"geofilesUpdateDialogDesc" = "Bu, tüm dosyaları güncelleyecektir." +"geofilesUpdateAll" = "Tümünü güncelle" "geofileUpdatePopover" = "Geofile başarıyla güncellendi" "dontRefresh" = "Kurulum devam ediyor, lütfen bu sayfayı yenilemeyin" "logs" = "Günlükler" diff --git a/web/translation/translate.uk_UA.toml b/web/translation/translate.uk_UA.toml index 46edca82..d181744e 100644 --- a/web/translation/translate.uk_UA.toml +++ b/web/translation/translate.uk_UA.toml @@ -132,6 +132,8 @@ "xraySwitchVersionPopover" = "Xray успішно оновлено" "geofileUpdateDialog" = "Ви дійсно хочете оновити геофайл?" "geofileUpdateDialogDesc" = "Це оновить файл #filename#." +"geofilesUpdateDialogDesc" = "Це оновить усі геофайли." +"geofilesUpdateAll" = "Оновити все" "geofileUpdatePopover" = "Геофайл успішно оновлено" "dontRefresh" = "Інсталяція триває, будь ласка, не оновлюйте цю сторінку" "logs" = "Журнали" diff --git a/web/translation/translate.vi_VN.toml b/web/translation/translate.vi_VN.toml index c73dc383..0283ae00 100644 --- a/web/translation/translate.vi_VN.toml +++ b/web/translation/translate.vi_VN.toml @@ -132,6 +132,8 @@ "xraySwitchVersionPopover" = "Xray đã được cập nhật thành công" "geofileUpdateDialog" = "Bạn có chắc chắn muốn cập nhật geofile không?" "geofileUpdateDialogDesc" = "Hành động này sẽ cập nhật tệp #filename#." +"geofilesUpdateDialogDesc" = "Thao tác này sẽ cập nhật tất cả các tập tin." +"geofilesUpdateAll" = "Cập nhật tất cả" "geofileUpdatePopover" = "Geofile đã được cập nhật thành công" "dontRefresh" = "Đang tiến hành cài đặt, vui lòng không làm mới trang này." "logs" = "Nhật ký" diff --git a/web/translation/translate.zh_CN.toml b/web/translation/translate.zh_CN.toml index ebe57f64..ba93e980 100644 --- a/web/translation/translate.zh_CN.toml +++ b/web/translation/translate.zh_CN.toml @@ -132,6 +132,8 @@ "xraySwitchVersionPopover" = "Xray 更新成功" "geofileUpdateDialog" = "您确定要更新地理文件吗?" "geofileUpdateDialogDesc" = "这将更新 #filename# 文件。" +"geofilesUpdateDialogDesc" = "这将更新所有文件。" +"geofilesUpdateAll" = "全部更新" "geofileUpdatePopover" = "地理文件更新成功" "dontRefresh" = "安装中,请勿刷新此页面" "logs" = "日志" diff --git a/web/translation/translate.zh_TW.toml b/web/translation/translate.zh_TW.toml index 694cd9f3..eef39ab6 100644 --- a/web/translation/translate.zh_TW.toml +++ b/web/translation/translate.zh_TW.toml @@ -132,6 +132,8 @@ "xraySwitchVersionPopover" = "Xray 更新成功" "geofileUpdateDialog" = "您確定要更新地理檔案嗎?" "geofileUpdateDialogDesc" = "這將更新 #filename# 檔案。" +"geofilesUpdateDialogDesc" = "這將更新所有文件。" +"geofilesUpdateAll" = "全部更新" "geofileUpdatePopover" = "地理檔案更新成功" "dontRefresh" = "安裝中,請勿重新整理此頁面" "logs" = "日誌"