fail2ban.server.jail module

class fail2ban.server.jail.Jail(name, backend='auto', db=None)

Fail2Ban jail, which manages a filter and associated actions.

The class handles the initialisation of a filter, and actions. It’s role is then to act as an interface between the filter and actions, passing bans detected by the filter, for the actions to then act upon.

Parameters:

name : str

Name assigned to the jail.

backend : str

Backend to be used for filter. “auto” will attempt to pick the most preferred backend method. Default: “auto”

db : Fail2BanDb

Fail2Ban persistent database instance. Default: None

Attributes

name Name of jail.
database The database used to store persistent data for the jail.
filter The filter which the jail is using to monitor log files.
actions Actions object used to manage actions for jail.
idle A boolean indicating whether jail is idle.
status The status of the jail.

Methods

getFailTicket() Get a fail ticket from the jail.
is_alive() Check jail “is_alive” by checking filter and actions threads.
putFailTicket(ticket) Add a fail ticket to the jail.
start() Start the jail, by starting filter and actions threads.
stop() Stop the jail, by stopping filter and actions threads.
actions

Actions object used to manage actions for jail.

database

The database used to store persistent data for the jail.

filter

The filter which the jail is using to monitor log files.

getFailTicket()

Get a fail ticket from the jail.

Used by actions to get a failure for banning.

idle

A boolean indicating whether jail is idle.

is_alive()

Check jail “is_alive” by checking filter and actions threads.

name

Name of jail.

putFailTicket(ticket)

Add a fail ticket to the jail.

Used by filter to add a failure for banning.

start()

Start the jail, by starting filter and actions threads.

Once stated, also queries the persistent database to reinstate any valid bans.

status

The status of the jail.

stop()

Stop the jail, by stopping filter and actions threads.