mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-08 14:14:19 +00:00
fix(iplimit): keep IP records working without fail2ban
This commit is contained in:
parent
03144a16ca
commit
c085fc3814
1 changed files with 9 additions and 6 deletions
|
|
@ -28,6 +28,7 @@ type IPWithTimestamp struct {
|
||||||
type CheckClientIpJob struct {
|
type CheckClientIpJob struct {
|
||||||
lastClear int64
|
lastClear int64
|
||||||
disAllowedIps []string
|
disAllowedIps []string
|
||||||
|
fail2BanWarned bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var job *CheckClientIpJob
|
var job *CheckClientIpJob
|
||||||
|
|
@ -45,7 +46,6 @@ func (j *CheckClientIpJob) Run() {
|
||||||
|
|
||||||
shouldClearAccessLog := false
|
shouldClearAccessLog := false
|
||||||
iplimitActive := j.hasLimitIp()
|
iplimitActive := j.hasLimitIp()
|
||||||
f2bInstalled := j.checkFail2BanInstalled()
|
|
||||||
isAccessLogAvailable := j.checkAccessLogAvailable(iplimitActive)
|
isAccessLogAvailable := j.checkAccessLogAvailable(iplimitActive)
|
||||||
|
|
||||||
if isAccessLogAvailable {
|
if isAccessLogAvailable {
|
||||||
|
|
@ -55,12 +55,15 @@ func (j *CheckClientIpJob) Run() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if iplimitActive {
|
if iplimitActive {
|
||||||
|
// Always process and persist client IP records. Fail2Ban is optional.
|
||||||
|
shouldClearAccessLog = j.processLogFile()
|
||||||
|
f2bInstalled := j.checkFail2BanInstalled()
|
||||||
|
if !f2bInstalled && !j.fail2BanWarned {
|
||||||
|
logger.Warning("[LimitIP] Fail2Ban is not installed, IP records will continue to work but automatic banning is disabled.")
|
||||||
|
j.fail2BanWarned = true
|
||||||
|
}
|
||||||
if f2bInstalled {
|
if f2bInstalled {
|
||||||
shouldClearAccessLog = j.processLogFile()
|
j.fail2BanWarned = false
|
||||||
} else {
|
|
||||||
if !f2bInstalled {
|
|
||||||
logger.Warning("[LimitIP] Fail2Ban is not installed, Please install Fail2Ban from the x-ui bash menu.")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue