fail2ban.server.jails module

class fail2ban.server.jails.Jails

Bases: _abcoll.Mapping

Handles the jails.

This class handles the jails. Creation, deletion or access to a jail must be done through this class. This class is thread-safe which is not the case of the jail itself, including filter and actions. This class is based on Mapping type, and the add method must be used to add additional jails.

Methods

add(name, backend[, db]) Adds a jail.
get((k[,d]) -> D[k] if k in D, ...)
items(() -> list of D’s (key, value) pairs, ...)
iteritems(() -> an iterator over the (key, ...)
iterkeys(() -> an iterator over the keys of D)
itervalues(...)
keys(() -> list of D’s keys)
values(() -> list of D’s values)
add(name, backend, db=None)

Adds a jail.

Adds a new jail if not already present which should use the given backend.

Parameters:

name : str

The name of the jail.

backend : str

The backend to use.

db : Fail2BanDb

Fail2Ban’s persistent database instance.

Raises:

DuplicateJailException

If jail name is already present.

get(k[, d]) → D[k] if k in D, else d. d defaults to None.
items() → list of D's (key, value) pairs, as 2-tuples
iteritems() → an iterator over the (key, value) items of D
iterkeys() → an iterator over the keys of D
itervalues() → an iterator over the values of D
keys() → list of D's keys
values() → list of D's values