diff --git a/bin/fail2ban-regex b/bin/fail2ban-regex index 4a32d6c7..5d06074a 100755 --- a/bin/fail2ban-regex +++ b/bin/fail2ban-regex @@ -88,6 +88,8 @@ IGNOREREGEX: version="%prog " + version) p.add_options([ + Option("-d", "--datepattern", + help="set custom pattern used to match date/times"), Option("-e", "--encoding", help="File encoding. Default: system locale"), Option("-L", "--maxlines", type=int, default=0, @@ -179,6 +181,9 @@ class Fail2banRegex(object): self._maxlines_set = False # so we allow to override maxlines in cmdline self._journalmatch = None + if opts.datepattern: + self.setDatePattern(opts.datepattern) + if opts.encoding: self.encoding = opts.encoding else: @@ -194,6 +199,8 @@ class Fail2banRegex(object): if opts.journalmatch is not None: self.setJournalMatch(opts.journalmatch.split()) + def setDatePattern(self, pattern): + self._filter.setDatePattern(pattern) def setMaxLines(self, v): if not self._maxlines_set: diff --git a/fail2ban/client/beautifier.py b/fail2ban/client/beautifier.py index 0c5e31fb..1c6cdaeb 100644 --- a/fail2ban/client/beautifier.py +++ b/fail2ban/client/beautifier.py @@ -119,6 +119,12 @@ class Beautifier: else: msg = "Current match filter:\n" msg += ' + '.join(" ".join(res) for res in 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 e0fb018d..25ad3b5c 100644 --- a/fail2ban/protocol.py +++ b/fail2ban/protocol.py @@ -63,6 +63,7 @@ protocol = [ ["set delignoreregex ", "removes the regular expression at for ignoreregex"], ["set findtime