Added seperate log file for IP Limit

This commit is contained in:
somebodywashere 2023-06-19 12:48:34 +00:00
parent d12ba90502
commit 577ba30913
2 changed files with 16 additions and 2 deletions

View file

@ -2,6 +2,7 @@ package job
import ( import (
"encoding/json" "encoding/json"
"log"
"os" "os"
"regexp" "regexp"
"x-ui/database" "x-ui/database"
@ -66,6 +67,13 @@ func hasLimitIp() bool {
for _, client := range clients { for _, client := range clients {
limitIp := client.LimitIP limitIp := client.LimitIP
if limitIp > 0 { if limitIp > 0 {
logIpFile, err := os.Create("/var/log/3xipl.log")
if err != nil {
log.Panic(err)
}
defer logIpFile.Close()
log.SetOutput(logIpFile)
log.SetFlags(log.LstdFlags)
return true return true
} }
} }
@ -242,7 +250,7 @@ func updateInboundClientIps(inboundClientIps *model.InboundClientIps, clientEmai
disAllowedIps = append(disAllowedIps, ips[limitIp:]...) disAllowedIps = append(disAllowedIps, ips[limitIp:]...)
for i := limitIp; i < len(ips); i++ { for i := limitIp; i < len(ips); i++ {
logger.Notice("[LIMIT_IP] Email=", clientEmail, " SRC=", ips[i]) log.Println("[LIMIT_IP] Email=", clientEmail, " SRC=", ips[i])
} }
} }
} }

View file

@ -746,7 +746,13 @@ install_iplimit() {
touch /var/log/3xipl-banned.log touch /var/log/3xipl-banned.log
fi fi
echo $'\n[3x-ipl]\nenabled=true\nfilter=3x-ipl\naction=3x-ipl\nlogpath=%(syslog_daemon)s\nmaxretry=3\nfindtime=100\nbantime=300' >> /etc/fail2ban/jail.local #Check if service log file exists so fail2ban fail2ban won't return error
if ! test -f "/var/log/3xipl.log"; then
touch /var/log/3xipl.log
fi
echo $'\n[3x-ipl]\nenabled=true\nfilter=3x-ipl\naction=3x-ipl\nlogpath=/var/log/3xipl.log\nmaxretry=3\nfindtime=100\nbantime=300' >> /etc/fail2ban/jail.local
echo $'[Definition]\nfailregex = [LIMIT_IP].+Email= <F-USER>.+</F-USER>.+SRC= <HOST>\nignoreregex =' > /etc/fail2ban/filter.d/3x-ipl.conf echo $'[Definition]\nfailregex = [LIMIT_IP].+Email= <F-USER>.+</F-USER>.+SRC= <HOST>\nignoreregex =' > /etc/fail2ban/filter.d/3x-ipl.conf