mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-09 19:56:19 +00:00
Update x-ui.sh
This commit is contained in:
parent
9dfe2cc476
commit
9777c6ee01
1 changed files with 13 additions and 16 deletions
29
x-ui.sh
29
x-ui.sh
|
@ -869,34 +869,32 @@ run_speedtest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
create_iplimit_jails() {
|
create_iplimit_jails() {
|
||||||
# Set default bantime to 30 minutes if not provided
|
# Use default bantime if not passed => 30 minutes
|
||||||
local bantime="${1:-30}"
|
local bantime="${1:-30}"
|
||||||
|
|
||||||
# Uncomment 'allowipv6 = auto' in fail2ban.conf
|
# Uncomment 'allowipv6 = auto' in fail2ban.conf
|
||||||
sed -i 's/#allowipv6 = auto/allowipv6 = auto/g' /etc/fail2ban/fail2ban.conf
|
sed -i 's/#allowipv6 = auto/allowipv6 = auto/g' /etc/fail2ban/fail2ban.conf
|
||||||
|
|
||||||
# Create 3x-ipl jail configuration
|
cat << EOF > /etc/fail2ban/jail.d/3x-ipl.conf
|
||||||
jail_config="[3x-ipl]
|
[3x-ipl]
|
||||||
enabled=true
|
enabled=true
|
||||||
filter=3x-ipl
|
filter=3x-ipl
|
||||||
action=3x-ipl
|
action=3x-ipl
|
||||||
logpath=${iplimit_log_path}
|
logpath=${iplimit_log_path}
|
||||||
maxretry=4
|
maxretry=4
|
||||||
findtime=60
|
findtime=60
|
||||||
bantime=${bantime}m"
|
bantime=${bantime}m
|
||||||
|
EOF
|
||||||
|
|
||||||
echo "$jail_config" >/etc/fail2ban/jail.d/3x-ipl.conf
|
cat << EOF > /etc/fail2ban/filter.d/3x-ipl.conf
|
||||||
|
[Definition]
|
||||||
# Create 3x-ipl filter definition
|
|
||||||
filter_definition="[Definition]
|
|
||||||
datepattern = ^%%Y/%%m/%%d %%H:%%M:%%S
|
datepattern = ^%%Y/%%m/%%d %%H:%%M:%%S
|
||||||
failregex = \[LIMIT_IP\]\s*Email\s*=\s*<F-USER>.+</F-USER>\s*\|\|\s*SRC\s*=\s*<ADDR>
|
failregex = \[LIMIT_IP\]\s*Email\s*=\s*<F-USER>.+</F-USER>\s*\|\|\s*SRC\s*=\s*<ADDR>
|
||||||
ignoreregex ="
|
ignoreregex =
|
||||||
|
EOF
|
||||||
|
|
||||||
echo "$filter_definition" >/etc/fail2ban/filter.d/3x-ipl.conf
|
cat << EOF > /etc/fail2ban/action.d/3x-ipl.conf
|
||||||
|
[INCLUDES]
|
||||||
# Create 3x-ipl action Definition
|
|
||||||
action_definition="[INCLUDES]
|
|
||||||
before = iptables-common.conf
|
before = iptables-common.conf
|
||||||
|
|
||||||
[Definition]
|
[Definition]
|
||||||
|
@ -916,9 +914,8 @@ actionban = <iptables> -I f2b-<name> 1 -s <ip> -j <blocktype>
|
||||||
actionunban = <iptables> -D f2b-<name> -s <ip> -j <blocktype>
|
actionunban = <iptables> -D f2b-<name> -s <ip> -j <blocktype>
|
||||||
echo "\$(date +"%%Y/%%m/%%d %%H:%%M:%%S") UNBAN [Email] = <F-USER> [IP] = <ip> unbanned." >> ${iplimit_banned_log_path}
|
echo "\$(date +"%%Y/%%m/%%d %%H:%%M:%%S") UNBAN [Email] = <F-USER> [IP] = <ip> unbanned." >> ${iplimit_banned_log_path}
|
||||||
|
|
||||||
[Init]"
|
[Init]
|
||||||
|
EOF
|
||||||
echo "$action_definition" >/etc/fail2ban/action.d/3x-ipl.conf
|
|
||||||
|
|
||||||
echo -e "${green}Ip Limit jail files created with a bantime of ${bantime} minutes.${plain}"
|
echo -e "${green}Ip Limit jail files created with a bantime of ${bantime} minutes.${plain}"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue