From 27f751671bb7649fc46f43639ff0bb08b3941075 Mon Sep 17 00:00:00 2001 From: Jacky Date: Tue, 8 Oct 2024 10:27:20 +0800 Subject: [PATCH] enhance: removed the ability to modify nginx log path settings online --- api/settings/settings.go | 3 +++ app/src/views/preference/NginxSettings.vue | 4 ++-- internal/nginx/config_args.go | 6 ++---- settings/nginx.go | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/api/settings/settings.go b/api/settings/settings.go index eee5e530..1c6ad46d 100644 --- a/api/settings/settings.go +++ b/api/settings/settings.go @@ -3,6 +3,7 @@ package settings import ( "github.com/0xJacky/Nginx-UI/api" "github.com/0xJacky/Nginx-UI/internal/cron" + "github.com/0xJacky/Nginx-UI/internal/nginx" "github.com/0xJacky/Nginx-UI/settings" "github.com/gin-gonic/gin" "net/http" @@ -15,6 +16,8 @@ func GetServerName(c *gin.Context) { } func GetSettings(c *gin.Context) { + settings.NginxSettings.AccessLogPath = nginx.GetAccessLogPath() + settings.NginxSettings.ErrorLogPath = nginx.GetErrorLogPath() c.JSON(http.StatusOK, gin.H{ "server": settings.ServerSettings, "nginx": settings.NginxSettings, diff --git a/app/src/views/preference/NginxSettings.vue b/app/src/views/preference/NginxSettings.vue index 3914c899..513eb9a5 100644 --- a/app/src/views/preference/NginxSettings.vue +++ b/app/src/views/preference/NginxSettings.vue @@ -14,7 +14,7 @@ const errors: Record> = inject('errors') as Recor ? $gettext('File not found') : ''" > - + {{ data.nginx.access_log_path }} > = inject('errors') as Recor ? $gettext('File not found') : ''" > - + {{ data.nginx.error_log_path }} diff --git a/internal/nginx/config_args.go b/internal/nginx/config_args.go index fdcb0b48..e6f71b31 100644 --- a/internal/nginx/config_args.go +++ b/internal/nginx/config_args.go @@ -33,12 +33,10 @@ func GetConfPath(dir ...string) (confPath string) { } joined := filepath.Clean(filepath.Join(confPath, filepath.Join(dir...))) - - if !helper.IsUnderDirectory(confPath, joined) { + if !helper.IsUnderDirectory(joined, confPath) { return confPath } - - return + return joined } func GetPIDPath() (path string) { diff --git a/settings/nginx.go b/settings/nginx.go index 62005fe9..9a4c9067 100644 --- a/settings/nginx.go +++ b/settings/nginx.go @@ -1,8 +1,8 @@ package settings type Nginx struct { - AccessLogPath string `json:"access_log_path" binding:"omitempty,file"` - ErrorLogPath string `json:"error_log_path" binding:"omitempty,file"` + AccessLogPath string `json:"access_log_path" protected:"true"` + ErrorLogPath string `json:"error_log_path" protected:"true"` ConfigDir string `json:"config_dir" protected:"true"` PIDPath string `json:"pid_path" protected:"true"` TestConfigCmd string `json:"test_config_cmd" protected:"true"`