From e5461d2b177c6ea58f67ffde2dbb59492044a9ab Mon Sep 17 00:00:00 2001
From: fgsfds <4870330+fgsfds@users.noreply.github.com>
Date: Tue, 5 Aug 2025 20:03:12 +0500
Subject: [PATCH] added Update all geofiles button
---
web/controller/server.go | 1 +
web/html/index.html | 13 ++++++--
web/service/server.go | 44 +++++++++++++++++++---------
web/translation/translate.ar_EG.toml | 1 +
web/translation/translate.en_US.toml | 1 +
web/translation/translate.es_ES.toml | 1 +
web/translation/translate.fa_IR.toml | 1 +
web/translation/translate.id_ID.toml | 1 +
web/translation/translate.ja_JP.toml | 1 +
web/translation/translate.pt_BR.toml | 1 +
web/translation/translate.ru_RU.toml | 1 +
web/translation/translate.tr_TR.toml | 1 +
web/translation/translate.uk_UA.toml | 1 +
web/translation/translate.vi_VN.toml | 1 +
web/translation/translate.zh_CN.toml | 1 +
web/translation/translate.zh_TW.toml | 1 +
16 files changed, 55 insertions(+), 16 deletions(-)
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..822f4b7a 100644
--- a/web/html/index.html
+++ b/web/html/index.html
@@ -383,6 +383,9 @@
+
@@ -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..477bf416 100644
--- a/web/translation/translate.ar_EG.toml
+++ b/web/translation/translate.ar_EG.toml
@@ -132,6 +132,7 @@
"xraySwitchVersionPopover" = "تم تحديث Xray بنجاح"
"geofileUpdateDialog" = "هل تريد حقًا تحديث ملف الجغرافيا؟"
"geofileUpdateDialogDesc" = "سيؤدي هذا إلى تحديث ملف #filename#."
+"geofilesUpdateDialogDesc" = "سيؤدي هذا إلى تحديث كافة الملفات."
"geofileUpdatePopover" = "تم تحديث ملف الجغرافيا بنجاح"
"dontRefresh" = "التثبيت شغال، متعملش Refresh للصفحة"
"logs" = "السجلات"
diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml
index 4ddef0da..476a0af5 100644
--- a/web/translation/translate.en_US.toml
+++ b/web/translation/translate.en_US.toml
@@ -132,6 +132,7 @@
"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."
"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..723cb603 100644
--- a/web/translation/translate.es_ES.toml
+++ b/web/translation/translate.es_ES.toml
@@ -132,6 +132,7 @@
"xraySwitchVersionPopover" = "Xray se actualizó correctamente"
"geofileUpdateDialog" = "¿Realmente deseas actualizar el geofichero?"
"geofileUpdateDialogDesc" = "Esto actualizará el archivo #filename#."
+"geofilesUpdateDialogDesc" = "Esto actualizará todos los archivos."
"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..78bbc740 100644
--- a/web/translation/translate.fa_IR.toml
+++ b/web/translation/translate.fa_IR.toml
@@ -132,6 +132,7 @@
"xraySwitchVersionPopover" = "Xray با موفقیت بهروز شد"
"geofileUpdateDialog" = "آیا واقعاً میخواهید فایل جغرافیایی را بهروز کنید؟"
"geofileUpdateDialogDesc" = "این عمل فایل #filename# را بهروز میکند."
+"geofilesUpdateDialogDesc" = "با این کار همه فایلها بهروزرسانی میشوند."
"geofileUpdatePopover" = "فایل جغرافیایی با موفقیت بهروز شد"
"dontRefresh" = "در حال نصب، لطفا صفحه را رفرش نکنید"
"logs" = "گزارشها"
diff --git a/web/translation/translate.id_ID.toml b/web/translation/translate.id_ID.toml
index 21e87dd7..8b8ece81 100644
--- a/web/translation/translate.id_ID.toml
+++ b/web/translation/translate.id_ID.toml
@@ -132,6 +132,7 @@
"xraySwitchVersionPopover" = "Xray berhasil diperbarui"
"geofileUpdateDialog" = "Apakah Anda yakin ingin memperbarui geofile?"
"geofileUpdateDialogDesc" = "Ini akan memperbarui file #filename#."
+"geofilesUpdateDialogDesc" = "Ini akan memperbarui semua berkas."
"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..99762c2a 100644
--- a/web/translation/translate.ja_JP.toml
+++ b/web/translation/translate.ja_JP.toml
@@ -132,6 +132,7 @@
"xraySwitchVersionPopover" = "Xrayの更新が成功しました"
"geofileUpdateDialog" = "ジオファイルを本当に更新しますか?"
"geofileUpdateDialogDesc" = "これにより#filename#ファイルが更新されます。"
+"geofilesUpdateDialogDesc" = "これにより、すべてのファイルが更新されます。"
"geofileUpdatePopover" = "ジオファイルの更新が成功しました"
"dontRefresh" = "インストール中、このページをリロードしないでください"
"logs" = "ログ"
diff --git a/web/translation/translate.pt_BR.toml b/web/translation/translate.pt_BR.toml
index a81f95fb..7036ccc1 100644
--- a/web/translation/translate.pt_BR.toml
+++ b/web/translation/translate.pt_BR.toml
@@ -132,6 +132,7 @@
"xraySwitchVersionPopover" = "Xray atualizado com sucesso"
"geofileUpdateDialog" = "Você realmente deseja atualizar o geofile?"
"geofileUpdateDialogDesc" = "Isso atualizará o arquivo #filename#."
+"geofilesUpdateDialogDesc" = "Isso atualizará todos os arquivos."
"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..2bfb7655 100644
--- a/web/translation/translate.ru_RU.toml
+++ b/web/translation/translate.ru_RU.toml
@@ -132,6 +132,7 @@
"xraySwitchVersionPopover" = "Xray успешно обновлён"
"geofileUpdateDialog" = "Вы действительно хотите обновить геофайл?"
"geofileUpdateDialogDesc" = "Это обновит файл #filename#."
+"geofilesUpdateDialogDesc" = "Это обновит все геофайлы."
"geofileUpdatePopover" = "Геофайл успешно обновлён"
"dontRefresh" = "Установка в процессе. Не обновляйте страницу"
"logs" = "Журнал"
diff --git a/web/translation/translate.tr_TR.toml b/web/translation/translate.tr_TR.toml
index 319b2a9e..e92d6c6a 100644
--- a/web/translation/translate.tr_TR.toml
+++ b/web/translation/translate.tr_TR.toml
@@ -132,6 +132,7 @@
"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."
"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..3e159944 100644
--- a/web/translation/translate.uk_UA.toml
+++ b/web/translation/translate.uk_UA.toml
@@ -132,6 +132,7 @@
"xraySwitchVersionPopover" = "Xray успішно оновлено"
"geofileUpdateDialog" = "Ви дійсно хочете оновити геофайл?"
"geofileUpdateDialogDesc" = "Це оновить файл #filename#."
+"geofilesUpdateDialogDesc" = "Це оновить усі геофайли."
"geofileUpdatePopover" = "Геофайл успішно оновлено"
"dontRefresh" = "Інсталяція триває, будь ласка, не оновлюйте цю сторінку"
"logs" = "Журнали"
diff --git a/web/translation/translate.vi_VN.toml b/web/translation/translate.vi_VN.toml
index c73dc383..6343a111 100644
--- a/web/translation/translate.vi_VN.toml
+++ b/web/translation/translate.vi_VN.toml
@@ -132,6 +132,7 @@
"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."
"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..9866e019 100644
--- a/web/translation/translate.zh_CN.toml
+++ b/web/translation/translate.zh_CN.toml
@@ -132,6 +132,7 @@
"xraySwitchVersionPopover" = "Xray 更新成功"
"geofileUpdateDialog" = "您确定要更新地理文件吗?"
"geofileUpdateDialogDesc" = "这将更新 #filename# 文件。"
+"geofilesUpdateDialogDesc" = "这将更新所有文件。"
"geofileUpdatePopover" = "地理文件更新成功"
"dontRefresh" = "安装中,请勿刷新此页面"
"logs" = "日志"
diff --git a/web/translation/translate.zh_TW.toml b/web/translation/translate.zh_TW.toml
index 694cd9f3..a8a72223 100644
--- a/web/translation/translate.zh_TW.toml
+++ b/web/translation/translate.zh_TW.toml
@@ -132,6 +132,7 @@
"xraySwitchVersionPopover" = "Xray 更新成功"
"geofileUpdateDialog" = "您確定要更新地理檔案嗎?"
"geofileUpdateDialogDesc" = "這將更新 #filename# 檔案。"
+"geofilesUpdateDialogDesc" = "這將更新所有文件。"
"geofileUpdatePopover" = "地理檔案更新成功"
"dontRefresh" = "安裝中,請勿重新整理此頁面"
"logs" = "日誌"