From f8f01d5ab771d9eff0f8f6a391b28456f419bf05 Mon Sep 17 00:00:00 2001 From: sebres Date: Mon, 9 Jul 2018 14:58:39 +0200 Subject: [PATCH] introduced new option `ignorecache` to improve performance of ignore failure check (using caching of `ignoreip`, `ignoreself` and `ignorecommand`) --- ChangeLog | 2 ++ fail2ban/client/jailreader.py | 1 + fail2ban/protocol.py | 3 +- fail2ban/server/filter.py | 54 ++++++++++++++++++++++++++------ fail2ban/server/server.py | 11 +++++-- fail2ban/server/transmitter.py | 6 ++++ fail2ban/tests/filtertestcase.py | 46 ++++++++++++++++++++++++--- fail2ban/tests/servertestcase.py | 9 +++++- man/jail.conf.5 | 14 ++++++++- 9 files changed, 127 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 782c557d..f54b4a71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -50,6 +50,8 @@ ver. 0.10.4-dev-1 (20??/??/??) - development edition * systemd: fixed type error on option `journalflags`: an integer is required (gh-2125); ### New Features +* new option `ignorecache` to improve performance of ignore failure check (using caching of `ignoreip`, + `ignoreself` and `ignorecommand`), see `man jail.conf` for syntax-example; * `ignorecommand` extended to use actions-similar replacement (capable to interpolate all possible tags like ``, ``, ``, `F-USER` etc.) diff --git a/fail2ban/client/jailreader.py b/fail2ban/client/jailreader.py index 72bf780d..b06ba72d 100644 --- a/fail2ban/client/jailreader.py +++ b/fail2ban/client/jailreader.py @@ -100,6 +100,7 @@ class JailReader(ConfigReader): ["string", "ignorecommand", None], ["bool", "ignoreself", None], ["string", "ignoreip", None], + ["string", "ignorecache", None], ["string", "filter", ""], ["string", "datepattern", None], ["string", "logtimezone", None], diff --git a/fail2ban/protocol.py b/fail2ban/protocol.py index 3625ec01..b21ab848 100644 --- a/fail2ban/protocol.py +++ b/fail2ban/protocol.py @@ -84,6 +84,8 @@ protocol = [ ["set ignoreself true|false", "allows the ignoring of own IP addresses"], ["set addignoreip ", "adds to the ignore list of "], ["set delignoreip ", "removes from the ignore list of "], +["set ignorecommand ", "sets ignorecommand of "], +["set ignorecache ", "sets ignorecache of "], ["set addlogpath ['tail']", "adds to the monitoring list of , optionally starting at the 'tail' of the file (default 'head')."], ["set dellogpath ", "removes from the monitoring list of "], ["set logencoding ", "sets the of the log files for "], @@ -91,7 +93,6 @@ protocol = [ ["set deljournalmatch ", "removes from the journal filter of "], ["set addfailregex ", "adds the regular expression which must match failures for "], ["set delfailregex ", "removes the regular expression at for failregex"], -["set ignorecommand ", "sets ignorecommand of "], ["set addignoreregex ", "adds the regular expression which should match pattern to exclude for "], ["set delignoreregex ", "removes the regular expression at for ignoreregex"], ["set findtime