Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/job/check_client_ip_job.go22
1 files changed, 12 insertions, 10 deletions
diff --git a/web/job/check_client_ip_job.go b/web/job/check_client_ip_job.go
index 64feeeb4..481d756b 100644
--- a/web/job/check_client_ip_job.go
+++ b/web/job/check_client_ip_job.go
@@ -36,10 +36,11 @@ func (j *CheckClientIpJob) Run() {
}
shouldClearAccessLog := false
+ iplimitActive := j.hasLimitIp()
f2bInstalled := j.checkFail2BanInstalled()
- isAccessLogAvailable := j.checkAccessLogAvailable()
+ isAccessLogAvailable := j.checkAccessLogAvailable(iplimitActive)
- if j.hasLimitIp() {
+ if iplimitActive {
if f2bInstalled && isAccessLogAvailable {
shouldClearAccessLog = j.processLogFile()
} else {
@@ -123,7 +124,7 @@ func (j *CheckClientIpJob) processLogFile() bool {
line := scanner.Text()
ipRegx, _ := regexp.Compile(`from \[?([0-9a-fA-F:.]+)\]?:\d+ accepted`)
- emailRegx, _ := regexp.Compile(`email:.+`)
+ emailRegx, _ := regexp.Compile(`email: (\S+)$`)
matches := ipRegx.FindStringSubmatch(line)
if len(matches) > 1 {
@@ -136,7 +137,7 @@ func (j *CheckClientIpJob) processLogFile() bool {
if matchesEmail == "" {
continue
}
- matchesEmail = strings.TrimSpace(strings.Split(matchesEmail, "email: ")[1])
+ matchesEmail = strings.Split(matchesEmail, "email: ")[1]
if InboundClientIps[matchesEmail] != nil {
if j.contains(InboundClientIps[matchesEmail], ip) {
@@ -174,19 +175,20 @@ func (j *CheckClientIpJob) checkFail2BanInstalled() bool {
return err == nil
}
-func (j *CheckClientIpJob) checkAccessLogAvailable() bool {
- isAvailable := true
+func (j *CheckClientIpJob) checkAccessLogAvailable(iplimitActive bool) bool {
accessLogPath, err := xray.GetAccessLogPath()
if err != nil {
return false
}
- switch accessLogPath {
- case "none", "":
- isAvailable = false
+ if accessLogPath == "none" || accessLogPath == "" {
+ if iplimitActive {
+ logger.Warning("Access log path is not set, and IP limit is active. Please configure the access log path.")
+ }
+ return false
}
- return isAvailable
+ return true
}
func (j *CheckClientIpJob) checkError(e error) {