mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
check fail2ban installed or not
This commit is contained in:
parent
4b4be5f837
commit
6765babe7b
1 changed files with 12 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -41,6 +42,7 @@ func (j *CheckClientIpJob) Run() {
|
||||||
|
|
||||||
// check for limit ip
|
// check for limit ip
|
||||||
if j.hasLimitIp() {
|
if j.hasLimitIp() {
|
||||||
|
j.checkFail2BanInstalled()
|
||||||
j.processLogFile()
|
j.processLogFile()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +76,16 @@ func (j *CheckClientIpJob) hasLimitIp() bool {
|
||||||
return false
|
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() {
|
func (j *CheckClientIpJob) processLogFile() {
|
||||||
accessLogPath := xray.GetAccessLogPath()
|
accessLogPath := xray.GetAccessLogPath()
|
||||||
if accessLogPath == "" {
|
if accessLogPath == "" {
|
||||||
|
|
Loading…
Reference in a new issue