From 20049dd3a07778731695ab5718160ff1c156e886 Mon Sep 17 00:00:00 2001 From: Steven Hiscocks Date: Sat, 4 May 2013 16:59:01 +0100 Subject: [PATCH] NF: Generate datetemplates from strptime format strings Can also set custom time format from fail2ban-client, replacing the default detectors --- fail2ban/client/beautifier.py | 6 ++ fail2ban/protocol.py | 2 + fail2ban/server/datedetector.py | 117 ++++++------------------- fail2ban/server/datetemplate.py | 47 +++++++++- fail2ban/server/filter.py | 35 ++++++++ fail2ban/server/server.py | 6 ++ fail2ban/server/transmitter.py | 6 ++ fail2ban/tests/datedetectortestcase.py | 2 +- 8 files changed, 130 insertions(+), 91 deletions(-) diff --git a/fail2ban/client/beautifier.py b/fail2ban/client/beautifier.py index a92e9520..e58f53ba 100644 --- a/fail2ban/client/beautifier.py +++ b/fail2ban/client/beautifier.py @@ -113,6 +113,12 @@ class Beautifier: elif inC[2] == "logencoding": msg = "Current log encoding is set to:\n" msg = msg + response + elif inC[2] == "datepattern": + msg = "Current date pattern set to: " + if response is None: + msg = msg + "Default Detectors" + else: + msg = msg + "%s (%s)" % response elif inC[2] in ("ignoreip", "addignoreip", "delignoreip"): if len(response) == 0: msg = "No IP address/network is ignored" diff --git a/fail2ban/protocol.py b/fail2ban/protocol.py index 334e7908..fb6c433d 100644 --- a/fail2ban/protocol.py +++ b/fail2ban/protocol.py @@ -64,6 +64,7 @@ protocol = [ ["set delignoreregex ", "removes the regular expression at for ignoreregex"], ["set findtime