fail2ban.helpers module¶
- class fail2ban.helpers.BgService¶
Bases:
object
Background servicing
Prevents memory leak on some platforms/python versions, using forced GC in periodical intervals.
Methods
service
- service(force=False, wait=False)¶
- class fail2ban.helpers.FormatterWithTraceBack(fmt, *args, **kwargs)¶
Bases:
Formatter
Custom formatter which expands %(tb) and %(tbc) with tracebacks
TODO: might need locking in case of compressed tracebacks
Methods
converter
([seconds])Convert seconds since the Epoch to a time tuple expressing local time.
format
(record)Format the specified record as text.
formatException
(ei)Format and return the specified exception information as a string.
formatStack
(stack_info)This method is provided as an extension point for specialized formatting of stack information.
formatTime
(record[, datefmt])Return the creation time of the specified LogRecord as formatted text.
usesTime
()Check if the format uses the creation time of the record.
formatMessage
- format(record)¶
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- class fail2ban.helpers.TraceBack(compress=False)¶
Bases:
object
Customized traceback to be included in debug messages
Methods
__call__
()Call self as a function.
- fail2ban.helpers.excepthook(exctype, value, traceback)¶
Except hook used to log unhandled exceptions to Fail2Ban log
- fail2ban.helpers.extractOptions(option)¶
- fail2ban.helpers.formatExceptionInfo()¶
Consistently format exception information
- fail2ban.helpers.getLogger(name)¶
Get logging.Logger instance with Fail2Ban logger name convention
- fail2ban.helpers.getVerbosityFormat(verbosity, fmt=' %(message)s', addtime=True, padding=True)¶
Custom log format for the verbose runs
- fail2ban.helpers.mbasename(s)¶
Custom function to include directory name if filename is too common
Also strip .py at the end
- fail2ban.helpers.prctl_set_th_name(name)¶
- fail2ban.helpers.splitWithOptions(option)¶
- fail2ban.helpers.splitwords(s)¶
Helper to split words on any comma, space, or a new line
Returns empty list if input is empty (or None) and filters out empty entries
- fail2ban.helpers.str2LogLevel(value)¶
- fail2ban.helpers.substituteRecursiveTags(inptags, conditional='', ignore=(), addrepl=None)¶
Sort out tag definitions within other tags. Since v.0.9.2 supports embedded interpolation (see test cases for examples).
so: becomes: a = 3 a = 3 b = <a>_3 b = 3_3
- Parameters:
- inptagsdict
Dictionary of tags(keys) and their values.
- Returns:
- dict
Dictionary of tags(keys) and their values, with tags within the values recursively replaced.
- fail2ban.helpers.uni_bytes(x)¶
- fail2ban.helpers.uni_decode(x, enc='UTF-8', errors='strict')¶
- fail2ban.helpers.uni_string(x)¶