fail2ban.server.jail module¶
- class fail2ban.server.jail.Jail(name, backend='auto', db=None)¶
Bases:
object
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:
- namestr
Name assigned to the jail.
- backendstr
Backend to be used for filter. “auto” will attempt to pick the most preferred backend method. Default: “auto”
- dbFail2BanDb
Fail2Ban persistent database instance. Default: None
- Attributes:
Methods
Get a fail ticket from the jail.
Returns max possible ban-time of jail.
isAlive
()Check jail "isAlive" by checking filter and actions threads.
putFailTicket
(ticket)Add a fail ticket to the jail.
restoreCurrentBans
([correctBanTime])Restore any previous valid bans from the database.
start
()Start the jail, by starting filter and actions threads.
status
([flavor])The status of the jail.
stop
([stop, join])Stop the jail, by stopping filter and actions threads.
getBanTimeExtra
setBanTimeExtra
- property actions¶
Actions object used to manage actions for jail.
- property database¶
The database used to store persistent data for the jail.
- property filter¶
The filter which the jail is using to monitor log files.
- getBanTimeExtra(opt=None)¶
- getFailTicket()¶
Get a fail ticket from the jail.
Used by actions to get a failure for banning.
- getMaxBanTime()¶
Returns max possible ban-time of jail.
- property hasFailTickets¶
Retrieve whether queue has tickets to ban.
- property idle¶
A boolean indicating whether jail is idle.
- isAlive()¶
Check jail “isAlive” by checking filter and actions threads.
- property name¶
Name of jail.
- putFailTicket(ticket)¶
Add a fail ticket to the jail.
Used by filter to add a failure for banning.
- restoreCurrentBans(correctBanTime=True)¶
Restore any previous valid bans from the database.
- setBanTimeExtra(opt, value)¶
- start()¶
Start the jail, by starting filter and actions threads.
Once stated, also queries the persistent database to reinstate any valid bans.
- status(flavor='basic')¶
The status of the jail.
- stop(stop=True, join=True)¶
Stop the jail, by stopping filter and actions threads.