diff options
| author | MHSanaei <ho3ein.sanaei@gmail.com> | 2023-09-01 12:53:50 +0300 |
|---|---|---|
| committer | MHSanaei <ho3ein.sanaei@gmail.com> | 2023-09-01 12:53:50 +0300 |
| commit | 6765babe7b740798a28dc91e16a7cd7d452890a3 (patch) | |
| tree | 7266fd89f093274a8c5c2aafb06d1b13384aa141 /web | |
| parent | 4b4be5f837ba4de807de63d62c478ba6055a4fb8 (diff) | |
check fail2ban installed or not
Diffstat (limited to 'web')
| -rw-r--r-- | web/job/check_client_ip_job.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/web/job/check_client_ip_job.go b/web/job/check_client_ip_job.go index 74ef3e09..b15473c5 100644 --- a/web/job/check_client_ip_job.go +++ b/web/job/check_client_ip_job.go @@ -4,6 +4,7 @@ import ( "encoding/json" "log" "os" + "os/exec" "regexp" "sort" "strings" @@ -41,6 +42,7 @@ func (j *CheckClientIpJob) Run() { // check for limit ip if j.hasLimitIp() { + j.checkFail2BanInstalled() j.processLogFile() } } @@ -74,6 +76,16 @@ func (j *CheckClientIpJob) hasLimitIp() bool { return false } +func (j *CheckClientIpJob) checkFail2BanInstalled() { + cmd := "fail2ban-client" + args := []string{"-h"} + + err := exec.Command(cmd, args...).Run() + if err != nil { + logger.Warning("fail2ban is not installed. IP limiting may not work properly.") + } +} + func (j *CheckClientIpJob) processLogFile() { accessLogPath := xray.GetAccessLogPath() if accessLogPath == "" { |
