mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-17 04:34:40 +03:00
[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
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user