From 618a5662837b0c70a88782ccb47e1cb634241bb3 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sat, 3 Feb 2024 17:54:04 +0330 Subject: [PATCH] new - select option for loglevel & access log --- web/html/xui/xray.html | 58 ++++++++++++++++++++++++++ web/job/check_client_ip_job.go | 8 +++- web/service/config.json | 5 ++- web/translation/translate.en_US.toml | 8 +++- web/translation/translate.es_ES.toml | 4 ++ web/translation/translate.fa_IR.toml | 4 ++ web/translation/translate.ru_RU.toml | 4 ++ web/translation/translate.vi_VN.toml | 4 ++ web/translation/translate.zh_Hans.toml | 4 ++ 9 files changed, 94 insertions(+), 5 deletions(-) diff --git a/web/html/xui/xray.html b/web/html/xui/xray.html index d00b73cc..267103cb 100644 --- a/web/html/xui/xray.html +++ b/web/html/xui/xray.html @@ -147,6 +147,40 @@ + + + + + + + + + + + + + + + + @@ -534,6 +568,8 @@ protocol: "freedom" }, routingDomainStrategies: ["AsIs", "IPIfNonMatch", "IPOnDemand"], + logLevel: ["none" , "debug" , "info" , "warning", "error"], + access: ["none" , "./access.log" ], settingsData: { protocols: { bittorrent: ["bittorrent"], @@ -1109,6 +1145,28 @@ this.templateSettings = newTemplateSettings; } }, + setLogLevel: { + get: function () { + if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.loglevel) return "warning"; + return this.templateSettings.log.loglevel; + }, + set: function (newValue) { + newTemplateSettings = this.templateSettings; + newTemplateSettings.log.loglevel = newValue; + this.templateSettings = newTemplateSettings; + } + }, + setAccessLog: { + get: function () { + if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.access) return "none"; + return this.templateSettings.log.access; + }, + set: function (newValue) { + newTemplateSettings = this.templateSettings; + newTemplateSettings.log.access = newValue; + this.templateSettings = newTemplateSettings; + } + }, blockedIPs: { get: function () { return this.templateRuleGetter({ outboundTag: "blocked", property: "ip" }); diff --git a/web/job/check_client_ip_job.go b/web/job/check_client_ip_job.go index ecfd5abb..77cbe256 100644 --- a/web/job/check_client_ip_job.go +++ b/web/job/check_client_ip_job.go @@ -94,8 +94,14 @@ func (j *CheckClientIpJob) checkFail2BanInstalled() { func (j *CheckClientIpJob) processLogFile() { accessLogPath := xray.GetAccessLogPath() + + if accessLogPath == "none" { + logger.Warning("Access log is set to 'none' check your Xray Configs") + return + } + if accessLogPath == "" { - logger.Warning("access.log doesn't exist in your config.json") + logger.Warning("Access log doesn't exist in your Xray Configs") return } diff --git a/web/service/config.json b/web/service/config.json index 82f7dddf..5c25ed92 100644 --- a/web/service/config.json +++ b/web/service/config.json @@ -1,7 +1,8 @@ { "log": { - "loglevel": "warning", - "error": "./error.log" + "access": "none", + "dnsLog": false, + "loglevel": "warning" }, "api": { "tag": "api", diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index 7e0f26c5..6295bf15 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -309,8 +309,8 @@ "restart" = "Restart Xray" "basicTemplate" = "Basics" "advancedTemplate" = "Advanced" -"generalConfigs" = "General Strategy" -"generalConfigsDesc" = "These options will determine general strategy adjustments." +"generalConfigs" = "General" +"generalConfigsDesc" = "These options will determine general adjustments." "blockConfigs" = "Protection Shield" "blockConfigsDesc" = "These options will block traffic based on specific requested protocols and websites." "blockCountryConfigs" = "Block Country" @@ -392,6 +392,10 @@ "Routings" = "Routing Rules" "RoutingsDesc" = "The priority of each rule is important!" "completeTemplate" = "All" +"logLevel" = "Log Level" +"logLevelDesc" = "The log level for error logs, indicating the information that needs to be recorded." +"accessLog" = "Access Log" +"accessLogDesc" = "The file path for the access log. The special value 'none' disabled access logs" [pages.xray.rules] "first" = "First" diff --git a/web/translation/translate.es_ES.toml b/web/translation/translate.es_ES.toml index ac9de9a4..b21fe252 100644 --- a/web/translation/translate.es_ES.toml +++ b/web/translation/translate.es_ES.toml @@ -392,6 +392,10 @@ "Routings" = "Reglas de enrutamiento" "RoutingsDesc" = "¡La prioridad de cada regla es importante!" "completeTemplate" = "Todos" +"logLevel" = "Nivel de registro" +"logLevelDesc" = "El nivel de registro para registros de errores, que indica la información que debe registrarse." +"accessLog" = "Registro de acceso" +"accessLogDesc" = "La ruta del archivo para el registro de acceso. El valor especial 'ninguno' deshabilita los registros de acceso" [pages.xray.rules] "first" = "Primero" diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml index 11b66788..e737c79b 100644 --- a/web/translation/translate.fa_IR.toml +++ b/web/translation/translate.fa_IR.toml @@ -392,6 +392,10 @@ "Routings" = "قوانین مسیریابی" "RoutingsDesc" = "اولویت هر قانون مهم است" "completeTemplate" = "کامل" +"logLevel" = "سطح گزارش" +"logLevelDesc" = "سطح گزارش برای گزارش های خطا، نشان دهنده اطلاعاتی است که باید ثبت شوند." +"accessLog" = "مسیر گزارش" +"accessLogDesc" = "مسیر فایل برای گزارش دسترسی. مقدار ویژه «هیچ» گزارش‌های دسترسی را غیرفعال میکند." [pages.xray.rules] "first" = "اولین" diff --git a/web/translation/translate.ru_RU.toml b/web/translation/translate.ru_RU.toml index 2e663e4c..cbd1d4f9 100644 --- a/web/translation/translate.ru_RU.toml +++ b/web/translation/translate.ru_RU.toml @@ -392,6 +392,10 @@ "Routings" = "Правила маршрутизации" "RoutingsDesc" = "Важен приоритет каждого правила!" "completeTemplate" = "Все" +"logLevel" = "Уровень журнала" +"logLevelDesc" = "Уровень журнала для журналов ошибок, указывающий информацию, которую необходимо записать." +"accessLog" = "Журнал доступа" +"accessLogDesc" = "Путь к файлу журнала доступа. Специальное значение «none» отключило журналы доступа." [pages.xray.rules] "first" = "Первый" diff --git a/web/translation/translate.vi_VN.toml b/web/translation/translate.vi_VN.toml index 4c40adca..f94b56b0 100644 --- a/web/translation/translate.vi_VN.toml +++ b/web/translation/translate.vi_VN.toml @@ -392,6 +392,10 @@ "Routings" = "Quy tắc định tuyến" "RoutingsDesc" = "Mức độ ưu tiên của mỗi quy tắc đều quan trọng!" "completeTemplate" = "All" +"logLevel" = "Mức đăng nhập" +"logLevelDesc" = "Cấp độ nhật ký cho nhật ký lỗi, cho biết thông tin cần được ghi lại." +"accessLog" = "Nhật ký truy cập" +"accessLogDesc" = "Đường dẫn tệp cho nhật ký truy cập. Nhật ký truy cập bị vô hiệu hóa có giá trị đặc biệt 'không'" [pages.xray.rules] "first" = "Đầu tiên" diff --git a/web/translation/translate.zh_Hans.toml b/web/translation/translate.zh_Hans.toml index a8cd3aff..d64e1331 100644 --- a/web/translation/translate.zh_Hans.toml +++ b/web/translation/translate.zh_Hans.toml @@ -392,6 +392,10 @@ "Routings" = "路由规则" "RoutingsDesc" = "每条规则的优先级都很重要" "completeTemplate" = "全部" +"logLevel" = "日志级别" +"logLevelDesc" = "错误日志的日志级别,表示需要记录的信息。" +"accessLog" = "访问日志" +"accessLogDesc" = "访问日志的文件路径。 特殊值“none”禁用访问日志" [pages.xray.rules] "first" = "第一个"