diff --git a/web/job/check_client_ip_job.go b/web/job/check_client_ip_job.go index 441f3521..c5e8fc0d 100644 --- a/web/job/check_client_ip_job.go +++ b/web/job/check_client_ip_job.go @@ -44,7 +44,7 @@ func (j *CheckClientIpJob) Run() { shouldClearAccessLog = j.processLogFile() } else { if !f2bInstalled { - logger.Warning("fail2ban is not installed. IP limiting may not work properly.") + logger.Warning("[iplimit] fail2ban is not installed. IP limiting may not work properly.") } } } @@ -109,13 +109,6 @@ func (j *CheckClientIpJob) hasLimitIp() bool { return false } -func (j *CheckClientIpJob) checkFail2BanInstalled() bool { - cmd := "fail2ban-client" - args := []string{"-h"} - err := exec.Command(cmd, args...).Run() - return err == nil -} - func (j *CheckClientIpJob) processLogFile() bool { accessLogPath, err := xray.GetAccessLogPath() j.checkError(err) @@ -174,15 +167,21 @@ func (j *CheckClientIpJob) processLogFile() bool { return shouldCleanLog } -func (j *CheckClientIpJob) checkAccessLogAvailable(doWarning bool) bool { +func (j *CheckClientIpJob) checkFail2BanInstalled() bool { + cmd := "fail2ban-client" + args := []string{"-h"} + err := exec.Command(cmd, args...).Run() + return err == nil +} + +func (j *CheckClientIpJob) checkAccessLogAvailable(handleWarning bool) bool { + isAvailable := true + warningMsg := "" accessLogPath, err := xray.GetAccessLogPath() if err != nil { return false } - isAvailable := true - warningMsg := "" - // access log is not available if it is set to 'none' or an empty string switch accessLogPath { case "none": @@ -193,7 +192,7 @@ func (j *CheckClientIpJob) checkAccessLogAvailable(doWarning bool) bool { isAvailable = false } - if doWarning && warningMsg != "" { + if handleWarning && warningMsg != "" { logger.Warning(warningMsg) } return isAvailable diff --git a/web/service/setting.go b/web/service/setting.go index 7750b6be..9e740059 100644 --- a/web/service/setting.go +++ b/web/service/setting.go @@ -463,7 +463,7 @@ func (s *SettingService) SetWarp(data string) error { func (s *SettingService) GetIpLimitEnable() (bool, error) { accessLogPath, err := xray.GetAccessLogPath() if err != nil { - return false, nil + return false, err } return (accessLogPath != "none" && accessLogPath != ""), nil }