From f8a269eaadf3040ee026bb1f68a614eaf3afe781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hasan=20=C3=87ALI=C5=9EIR?= Date: Wed, 5 Mar 2025 21:15:10 +0300 Subject: [PATCH] fix convert_bantime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Swapped returns for echoes — Bash, not PHP --- files/fail2ban-abuseipdb.sh | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/files/fail2ban-abuseipdb.sh b/files/fail2ban-abuseipdb.sh index 86bbb3c5..a21a3425 100644 --- a/files/fail2ban-abuseipdb.sh +++ b/files/fail2ban-abuseipdb.sh @@ -268,7 +268,6 @@ check_ip_in_abuseipdb() { http_status="${response##*${delimiter}}" body="${response%"${delimiter}${http_status}"}" - if [[ ! "${http_status}" =~ ^[0-9]+$ ]]; then log_message "ERROR: Invalid HTTP status in Response: ${response}" return 2 @@ -291,10 +290,7 @@ check_ip_in_abuseipdb() { } convert_bantime() { - local bantime=$1 - local time_value - local time_unit - + local bantime=$1 time_value time_unit if [[ "${bantime}" =~ ^[0-9]+$ ]]; then echo "${bantime}" return 0 @@ -304,15 +300,14 @@ convert_bantime() { time_unit="${bantime#${time_value}}" [[ -z "$time_unit" ]] && time_unit="s" - case "$time_unit" in - s) return $time_value ;; - m) return $((time_value * 60)) ;; - h) return $((time_value * 3600)) ;; - d) return $((time_value * 86400)) ;; - w) return $((time_value * 604800)) ;; - y) return $((time_value * 31536000)) ;; - *) return $time_value ;; + s) echo "$time_value" ;; + m) echo "$((time_value * 60))" ;; + h) echo "$((time_value * 3600))" ;; + d) echo "$((time_value * 86400))" ;; + w) echo "$((time_value * 604800))" ;; + y) echo "$((time_value * 31536000))" ;; + *) echo "${time_value}" ;; esac }