From 625b7b8047791e5b66a576b9c36979d59fdc4ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Tue, 28 Oct 2025 22:23:33 +0100 Subject: [PATCH] fix w trackerze --- logmon.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/logmon.py b/logmon.py index 4ec831b..c4bb600 100644 --- a/logmon.py +++ b/logmon.py @@ -150,6 +150,10 @@ class LogMonDaemon: ip: Adres IP atakującego score: Punkty za dane niepowodzenie (domyślnie 1) """ + if ip in self.banned_ips: + self.logger.debug(f"IP {ip} already banned, ignoring") + return + now = datetime.now() # Dodaj wpis do trackera @@ -157,7 +161,7 @@ class LogMonDaemon: # Usuń stare wpisy spoza okna czasowego time_window = self.config.getint('module_postfix', 'time_window', - fallback=60) + fallback=60) cutoff = now - timedelta(seconds=time_window) while self.ip_tracker[ip] and self.ip_tracker[ip][0][0] < cutoff: @@ -168,17 +172,16 @@ class LogMonDaemon: failures_count = len(self.ip_tracker[ip]) max_failures = self.config.getint('module_postfix', 'max_failures', - fallback=5) + fallback=5) self.logger.debug( f"IP {ip}: {failures_count} failures, score {total_score}/{max_failures}" ) # Sprawdź czy przekroczono limit - if total_score >= max_failures and ip not in self.banned_ips: + if total_score >= max_failures: self.ban_ip(ip) - elif total_score >= max_failures and ip in self.banned_ips: - self.logger.debug(f"IP {ip} already banned, ignoring") + def ban_ip(self, ip): """