diff --git a/x-ui.sh b/x-ui.sh index 93811acbd0..3d6241470e 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -1358,10 +1358,12 @@ iplimit_main() { echo -e "${green}\t2.${plain} Change Ban Duration" echo -e "${green}\t3.${plain} Unban Everyone" echo -e "${green}\t4.${plain} Ban Logs" - echo -e "${green}\t5.${plain} Real-Time Logs" - echo -e "${green}\t6.${plain} Service Status" - echo -e "${green}\t7.${plain} Service Restart" - echo -e "${green}\t8.${plain} Uninstall Fail2ban and IP Limit" + echo -e "${green}\t5.${plain} Unban an IP Address" + echo -e "${green}\t6.${plain} Ban an IP Address" + echo -e "${green}\t7.${plain} Real-Time Logs" + echo -e "${green}\t8.${plain} Service Status" + echo -e "${green}\t9.${plain} Service Restart" + echo -e "${green}\t10.${plain} Uninstall Fail2ban and IP Limit" echo -e "${green}\t0.${plain} Back to Main Menu" read -p "Choose an option: " choice case "$choice" in @@ -1389,7 +1391,7 @@ iplimit_main() { 3) confirm "Proceed with Unbanning everyone from IP Limit jail?" "y" if [[ $? == 0 ]]; then - fail2ban-client set 3x-ipl unban --all + systemctl restart fail2ban truncate -s 0 "${iplimit_banned_log_path}" echo -e "${green}All users Unbanned successfully.${plain}" iplimit_main @@ -1403,18 +1405,38 @@ iplimit_main() { iplimit_main ;; 5) - tail -f /var/log/fail2ban.log + read -rp "Enter the IP address you want to ban: " ban_ip + if [[ $ban_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + fail2ban-client set 3x-ipl banip "$ban_ip" + echo -e "${green}IP Address ${ban_ip} has been banned successfully.${plain}" + else + echo -e "${red}Invalid IP address format! Please try again.${plain}" + fi iplimit_main ;; 6) - service fail2ban status + read -rp "Enter the IP address you want to unban: " unban_ip + if [[ $unban_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + fail2ban-client set 3x-ipl unbanip "$unban_ip" + echo -e "${green}IP Address ${unban_ip} has been unbanned successfully.${plain}" + else + echo -e "${red}Invalid IP address format! Please try again.${plain}" + fi iplimit_main ;; 7) - systemctl restart fail2ban + tail -f /var/log/fail2ban.log iplimit_main ;; 8) + service fail2ban status + iplimit_main + ;; + 9) + systemctl restart fail2ban + iplimit_main + ;; + 10) remove_iplimit iplimit_main ;;