mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-08-30 06:46:17 +00:00
Added seperate log file for IP Limit
This commit is contained in:
parent
d12ba90502
commit
577ba30913
2 changed files with 16 additions and 2 deletions
|
@ -2,6 +2,7 @@ package job
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
"regexp"
|
||||
"x-ui/database"
|
||||
|
@ -66,6 +67,13 @@ func hasLimitIp() bool {
|
|||
for _, client := range clients {
|
||||
limitIp := client.LimitIP
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +250,7 @@ func updateInboundClientIps(inboundClientIps *model.InboundClientIps, clientEmai
|
|||
|
||||
disAllowedIps = append(disAllowedIps, ips[limitIp:]...)
|
||||
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])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
8
x-ui.sh
8
x-ui.sh
|
@ -746,7 +746,13 @@ install_iplimit() {
|
|||
touch /var/log/3xipl-banned.log
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue