fail2ban.server.filter module

class fail2ban.server.filter.FileContainer(filename, encoding, tail=False, doOpen=False)

Bases: object

Methods

readline([complete])

Read line from file

close

decode_line

getEncoding

getFileName

getFileSize

getHash

getPos

open

seek

setEncoding

setPos

tell

close()
static decode_line(filename, enc, line)
getEncoding()
getFileName()
getFileSize()
getHash()
getPos()
open(forcePos=None)
readline(complete=True)

Read line from file

In opposite to pythons readline it doesn’t return new-line, so returns either the line if line is complete (and complete=True) or None if line is not complete (and complete=True) or there is no content to read. If line is complete (and complete is True), it also shift current known position to begin of next line.

Also it is safe against interim new-line bytes (e. g. part of multi-byte char) in given encoding.

seek(offs, endLine=True)
setEncoding(encoding)
setPos(value)
tell()
class fail2ban.server.filter.FileFilter(jail, **kwargs)

Bases: Filter

Attributes:
daemon

A boolean value indicating whether this thread is a daemon thread.

ident

Thread identifier of this thread or None if it has not been started.

ignoreCache
ignoreCommand
ignoreSelf
jailName
mlfidCache
name

A string used for identification purposes only.

native_id

Native integral thread ID of this thread, or None if it has not been started.

prefRegex

Methods

addAttempt(ip, *matches)

Generate a failed attempt for ip

clearAllParams()

Clear all lists/dicts parameters (used by reloading)

getName()

Return a string used for identification purposes only.

isAlive()

Return whether the thread is alive.

isDaemon()

Return whether this thread is a daemon.

is_alive()

Return whether the thread is alive.

join()

Safer join, that could be called also for not started (or ended) threads (used for cleanup).

onStop()

Stop monitoring of log-file(s).

performBan([ip])

Performs a ban for IPs (or given ip) that are reached maxretry of the jail.

performSvc([force])

Performs a service tasks (clean failure list).

processLine(line[, date])

Split the time portion from log msg and return findFailures on them

processLineAndAdd(line[, date])

Processes the line for failures and populates failManager

reload([begin])

Begin or end of reloading resp.

run()

Abstract - Called when thread starts, thread stops when returns.

setDaemon(daemonic)

Set whether this thread is a daemon.

setName(name)

Set the name string for this thread.

start()

Sets active flag and starts thread.

status([flavor])

Status of Filter plus files being monitored.

stop()

Stop filter

addFailRegex

addIgnoreIP

addIgnoreRegex

addLogPath

commonError

containsLogPath

delFailRegex

delIgnoreIP

delIgnoreRegex

delLogPath

findFailure

getDatePattern

getFailRegex

getFailures

getFindTime

getIgnoreIP

getIgnoreRegex

getLog

getLogCount

getLogEncoding

getLogPaths

getLogTimeZone

getLogs

getMaxLines

getMaxRetry

getUseDns

inIgnoreIPList

logIgnoreIp

seekToTime

setDatePattern

setFindTime

setLogEncoding

setLogTimeZone

setMaxLines

setMaxRetry

setUseDns

addLogPath(path, tail=False, autoSeek=True)
containsLogPath(path)
delLogPath(path)
getFailures(filename, inOperation=None)
getLog(path)
getLogCount()
getLogPaths()
getLogs()
onStop()

Stop monitoring of log-file(s). Invoked after run method.

seekToTime(container, date, accuracy=3)
setLogEncoding(encoding)
status(flavor='basic')

Status of Filter plus files being monitored.

stop()

Stop filter

class fail2ban.server.filter.Filter(jail, useDns='warn')

Bases: JailThread

Attributes:
daemon

A boolean value indicating whether this thread is a daemon thread.

ident

Thread identifier of this thread or None if it has not been started.

ignoreCache
ignoreCommand
ignoreSelf
jailName
mlfidCache
name

A string used for identification purposes only.

native_id

Native integral thread ID of this thread, or None if it has not been started.

prefRegex

Methods

addAttempt(ip, *matches)

Generate a failed attempt for ip

clearAllParams()

Clear all lists/dicts parameters (used by reloading)

getName()

Return a string used for identification purposes only.

isAlive()

Return whether the thread is alive.

isDaemon()

Return whether this thread is a daemon.

is_alive()

Return whether the thread is alive.

join()

Safer join, that could be called also for not started (or ended) threads (used for cleanup).

onStop()

Abstract - Called when thread ends (after run).

performBan([ip])

Performs a ban for IPs (or given ip) that are reached maxretry of the jail.

performSvc([force])

Performs a service tasks (clean failure list).

processLine(line[, date])

Split the time portion from log msg and return findFailures on them

processLineAndAdd(line[, date])

Processes the line for failures and populates failManager

reload([begin])

Begin or end of reloading resp.

run()

Abstract - Called when thread starts, thread stops when returns.

setDaemon(daemonic)

Set whether this thread is a daemon.

setName(name)

Set the name string for this thread.

start()

Sets active flag and starts thread.

status([flavor])

Status of failures detected by filter.

stop()

Sets active property to False, to flag run method to return.

addFailRegex

addIgnoreIP

addIgnoreRegex

commonError

delFailRegex

delIgnoreIP

delIgnoreRegex

findFailure

getDatePattern

getFailRegex

getFindTime

getIgnoreIP

getIgnoreRegex

getLogEncoding

getLogTimeZone

getMaxLines

getMaxRetry

getUseDns

inIgnoreIPList

logIgnoreIp

setDatePattern

setFindTime

setLogEncoding

setLogTimeZone

setMaxLines

setMaxRetry

setUseDns

addAttempt(ip, *matches)

Generate a failed attempt for ip

addFailRegex(value)
addIgnoreIP(ipstr)
addIgnoreRegex(value)
clearAllParams()

Clear all lists/dicts parameters (used by reloading)

commonError(reason='common', exc=None)
delFailRegex(index=None)
delIgnoreIP(ip=None)
delIgnoreRegex(index=None)
findFailure(tupleLine, date, noDate=False)
getDatePattern()
getFailRegex()
getFindTime()
getIgnoreIP()
getIgnoreRegex()
getLogEncoding()
getLogTimeZone()
getMaxLines()
getMaxRetry()
getUseDns()
property ignoreCache
property ignoreCommand
property ignoreSelf
inIgnoreIPList(ip, log_ignore=True)
property jailName
logIgnoreIp(ip, log_ignore, ignore_source='unknown source')
property mlfidCache
performBan(ip=None)

Performs a ban for IPs (or given ip) that are reached maxretry of the jail.

performSvc(force=False)

Performs a service tasks (clean failure list).

property prefRegex
processLine(line, date=None)

Split the time portion from log msg and return findFailures on them

processLineAndAdd(line, date=None)

Processes the line for failures and populates failManager

reload(begin=True)

Begin or end of reloading resp. refreshing of all parameters

run()

Abstract - Called when thread starts, thread stops when returns.

setDatePattern(pattern)
setFindTime(value)
setLogEncoding(encoding)
setLogTimeZone(tz)
setMaxLines(value)
setMaxRetry(value)
setUseDns(value)
status(flavor='basic')

Status of failures detected by filter.

class fail2ban.server.filter.JournalFilter(jail, useDns='warn')

Bases: Filter

Attributes:
daemon

A boolean value indicating whether this thread is a daemon thread.

ident

Thread identifier of this thread or None if it has not been started.

ignoreCache
ignoreCommand
ignoreSelf
jailName
mlfidCache
name

A string used for identification purposes only.

native_id

Native integral thread ID of this thread, or None if it has not been started.

prefRegex

Methods

addAttempt(ip, *matches)

Generate a failed attempt for ip

clearAllParams()

Clear all lists/dicts parameters (used by reloading)

getName()

Return a string used for identification purposes only.

isAlive()

Return whether the thread is alive.

isDaemon()

Return whether this thread is a daemon.

is_alive()

Return whether the thread is alive.

join()

Safer join, that could be called also for not started (or ended) threads (used for cleanup).

onStop()

Abstract - Called when thread ends (after run).

performBan([ip])

Performs a ban for IPs (or given ip) that are reached maxretry of the jail.

performSvc([force])

Performs a service tasks (clean failure list).

processLine(line[, date])

Split the time portion from log msg and return findFailures on them

processLineAndAdd(line[, date])

Processes the line for failures and populates failManager

reload([begin])

Begin or end of reloading resp.

run()

Abstract - Called when thread starts, thread stops when returns.

setDaemon(daemonic)

Set whether this thread is a daemon.

setName(name)

Set the name string for this thread.

start()

Sets active flag and starts thread.

status([flavor])

Status of failures detected by filter.

stop()

Sets active property to False, to flag run method to return.

addFailRegex

addIgnoreIP

addIgnoreRegex

addJournalMatch

commonError

delFailRegex

delIgnoreIP

delIgnoreRegex

delJournalMatch

findFailure

getDatePattern

getFailRegex

getFindTime

getIgnoreIP

getIgnoreRegex

getJournalMatch

getLogEncoding

getLogTimeZone

getMaxLines

getMaxRetry

getUseDns

inIgnoreIPList

logIgnoreIp

setDatePattern

setFindTime

setLogEncoding

setLogTimeZone

setMaxLines

setMaxRetry

setUseDns

addJournalMatch(match)
clearAllParams()

Clear all lists/dicts parameters (used by reloading)

delJournalMatch(match=None)
getJournalMatch(match)