From c4b906223ce1a105e16642a88b69e01e18ab6437 Mon Sep 17 00:00:00 2001 From: boban Date: Fri, 31 Oct 2025 03:18:53 +0100 Subject: [PATCH] =?UTF-8?q?Fix:=20Mailbox=20Stats=20=C3=BCber=20Dovecot=20?= =?UTF-8?q?mit=20config/mailpool.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ui/Security/Modal/Fail2BanJailModal.php | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/app/Livewire/Ui/Security/Modal/Fail2BanJailModal.php b/app/Livewire/Ui/Security/Modal/Fail2BanJailModal.php index 696dbc3..e2de874 100644 --- a/app/Livewire/Ui/Security/Modal/Fail2BanJailModal.php +++ b/app/Livewire/Ui/Security/Modal/Fail2BanJailModal.php @@ -74,7 +74,7 @@ class Fail2BanJailModal extends ModalComponent $this->rows = $rows; } - + /** ROBUST: findet Binaries automatisch */ private function bin(string $name): string { @@ -191,7 +191,10 @@ class Fail2BanJailModal extends ModalComponent $db = $this->getDbFile(); $q = sprintf( - "SELECT timeofban, expiretime FROM bans WHERE jail=%s AND ip=%s ORDER BY timeofban DESC LIMIT 1", + "SELECT timeofban, expiretime + FROM bans + WHERE jail=%s AND ip=%s AND (expiretime=-1 OR expiretime>STRFTIME('%%s','now')) + ORDER BY timeofban DESC LIMIT 1", $this->sql($jail), $this->sql($ip) ); @@ -203,12 +206,24 @@ class Fail2BanJailModal extends ModalComponent [$timeofban, $expire] = array_map('intval', explode('|', $out)) + [null, null]; return ['banned_at' => $timeofban ?: null, 'expire' => $expire ?? null]; } - + private function isStillBanned(string $jail, string $ip): bool { - [, $out] = $this->f2b('get '.escapeshellarg($jail).' banip '.escapeshellarg($ip)); - // gibt in der Regel "1" (banned) oder nichts/0 zurück - return (bool)preg_match('/\b1\b/', $out); + // 1) Direkt: banip + [, $out1] = $this->f2b('get '.escapeshellarg($jail).' banip '.escapeshellarg($ip)); + if (preg_match('/\b1\b/', $out1)) return true; + + // 2) Liste: banlist (Rohliste, whitespace-separiert) + [, $out2] = $this->f2b('get '.escapeshellarg($jail).' banlist'); + if ($out2 !== '') { + $list = array_filter(array_map('trim', preg_split('/\s+/', trim($out2)))); + if (in_array($ip, $list, true)) return true; + } + + // 3) Notfall: status-Parsing + [, $out3] = $this->f2b('status '.escapeshellarg($jail)); + $ipList = $this->firstMatch('/Banned IP list:\s*(.+)$/mi', $out3) ?: ''; + return $ipList !== '' && preg_match('/(^|\s)'.preg_quote($ip,'/').'(\s|$)/', $ipList) === 1; } private function getBantime(string $jail): int