diff --git a/fail2ban/client/beautifier.py b/fail2ban/client/beautifier.py index 97cd38b2..1c59016f 100644 --- a/fail2ban/client/beautifier.py +++ b/fail2ban/client/beautifier.py @@ -185,7 +185,7 @@ class Beautifier: sep = " " if len(inC) <= 3 else inC[3] if sep == "--with-time": sep = "\n" - msg = sep.join(response) + msg = sep.join([str(res) for res in response]) except Exception: logSys.warning("Beautifier error. Please report the error") logSys.error("Beautify %r with %r failed", response, self.__inputCmd, diff --git a/fail2ban/helpers.py b/fail2ban/helpers.py index fa16693a..815ecf63 100644 --- a/fail2ban/helpers.py +++ b/fail2ban/helpers.py @@ -28,6 +28,7 @@ import re import sys import traceback +from ast import literal_eval from threading import Lock from .server.mytime import MyTime @@ -298,6 +299,16 @@ def _merge_copy_dicts(x, y): """ return {**x, **y} +def parseExpressions(value): + def parseExpr(v): + try: + return literal_eval(v) + except SyntaxError: + return v + if value: + return list(map(parseExpr, value)) if isinstance(value, (list, tuple)) else parseExpr(value) + return None + # # Following function used for parse options from parameter (e.g. `name[p1=0, p2="..."][p3='...']`). # diff --git a/fail2ban/protocol.py b/fail2ban/protocol.py index 28c490fc..4182d67c 100644 --- a/fail2ban/protocol.py +++ b/fail2ban/protocol.py @@ -56,7 +56,7 @@ protocol = [ ["unban --all", "unbans all IP addresses (in all jails and database)"], ["unban [--expr] [--] ... ", "unbans (in all jails and database)"], ["banned", "return jails with banned IPs as dictionary"], -["banned ... ]", "return list(s) of jails where given IP(s) are banned"], +["banned [--expr] [--] ... ]", "return list(s) of jails where given IP(s) are banned"], ["status", "gets the current status of the server"], ["ping", "tests if the server is alive"], ["echo", "for internal usage, returns back and outputs a given string"], @@ -86,8 +86,8 @@ protocol = [ ['', "JAIL CONFIGURATION", ""], ["set idle on|off", "sets the idle state of "], ["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 addignoreip [--expr] [--] ... ", "adds to the ignore list of "], +["set delignoreip [--expr] [--] ... ", "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')."], @@ -103,8 +103,8 @@ protocol = [ ["set bantime