From 569c9428fb7924fb693605385f745e4bf524dc20 Mon Sep 17 00:00:00 2001 From: Hamidreza <70919649+hamid-gh98@users.noreply.github.com> Date: Wed, 13 Mar 2024 11:24:41 +0330 Subject: [iplimit] fix access log path in settings service (#2044) * [iplimit] fix access log path in settings service better to avoid hardcoding the access log path to enhance flexibility. not all users prefer the default './access.log' * [iplimit] fix iplimit --- web/service/setting.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'web/service') diff --git a/web/service/setting.go b/web/service/setting.go index 4a293dc0..9e740059 100644 --- a/web/service/setting.go +++ b/web/service/setting.go @@ -17,6 +17,7 @@ import ( "x-ui/util/random" "x-ui/util/reflect_util" "x-ui/web/entity" + "x-ui/xray" ) //go:embed config.json @@ -460,22 +461,11 @@ func (s *SettingService) SetWarp(data string) error { } func (s *SettingService) GetIpLimitEnable() (bool, error) { - templateConfig, err := s.GetXrayConfigTemplate() + accessLogPath, err := xray.GetAccessLogPath() if err != nil { return false, err } - - var xrayConfig map[string]interface{} - err = json.Unmarshal([]byte(templateConfig), &xrayConfig) - if err != nil { - return false, err - } - if logConfig, ok := xrayConfig["log"].(map[string]interface{}); ok { - if accessLogPath, ok := logConfig["access"].(string); ok { - return accessLogPath == "./access.log", nil - } - } - return false, nil + return (accessLogPath != "none" && accessLogPath != ""), nil } func (s *SettingService) UpdateAllSetting(allSetting *entity.AllSetting) error { -- cgit v1.2.3