From d96c04468fce4112d9ccb6c290e604d962f3c964 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 16 May 2018 00:09:46 +0200 Subject: [PATCH] fail2ban IPs that ignore redirects --- utils/cron_ipanalyse.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/cron_ipanalyse.py b/utils/cron_ipanalyse.py index 35db7759..66d122cd 100755 --- a/utils/cron_ipanalyse.py +++ b/utils/cron_ipanalyse.py @@ -253,8 +253,8 @@ class IPstats: def add_block(self, logentry): self.block_total += 1 - def ignores_warnings(self): - return self.block_total > 5 + def ignores_warnings(self, wasblocked): + return self.block_total > 5 or (wasblocked and self.redirected > 5) def new_state(self, was_blocked, was_bulked): if was_blocked: @@ -397,6 +397,6 @@ if __name__ == '__main__': if blocked: fd.write(logstr % ('new block:', ', '.join(blocked))) for k,v in stats.items(): - if v.ignores_warnings() and k not in notlogged and ':' not in k: + if v.ignores_warnings(k in bl.prevblocks) and k not in notlogged and ':' not in k: fd.write(logstr % ('Warning ignored:', k)) fd.close() -- 2.39.5