fail2ban.server.datetemplate module
***********************************

class fail2ban.server.datetemplate.DateEpoch

   Bases: "fail2ban.server.datetemplate.DateTemplate"

   A date template which searches for Unix timestamps.

   This includes Unix timestamps which appear at start of a line,
   optionally within square braces (nsd), or on SELinux audit log
   lines.

   Attributes:
      "name"
         Name assigned to template.

      "regex"
         Regex used to search for date.

   -[ Methods ]-

   +------------+--------------------------------------------------------------------------------------------+
   | "getDate"  | Method to return the date for a log line.                                                  |
   | (self,     |                                                                                            |
   | line)      |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+
   | "matchDat  | Check if regex for date matches on a log line.                                             |
   | e"(self,   |                                                                                            |
   | line)      |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+
   | "setRegex  | Sets regex to use for searching for date in log line.                                      |
   | "(self,    |                                                                                            |
   | regex[,    |                                                                                            |
   | wordBegin, |                                                                                            |
   | wordEnd])  |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+

   +--------------+------------+
   | **getRegex** |            |
   +--------------+------------+

   getDate(self, line)

      Method to return the date for a log line.

      Parameters:
         **line** : str
            Log line, of which the date should be extracted from.

      Returns:
         (float, str)
            Tuple containing a Unix timestamp, and the string of the
            date which was matched and in turned used to calculated
            the timestamp.

   getRegex(self)

   matchDate(self, line)

      Check if regex for date matches on a log line.

   property name

      Name assigned to template.

   property regex

      Regex used to search for date.

   setRegex(self, regex, wordBegin=True, wordEnd=True)

      Sets regex to use for searching for date in log line.

      Parameters:
         **regex** : str
            The regex the template will use for searching for a date.

         **wordBegin** : bool
            Defines whether the regex should be modified to search at
            beginning of a word, by adding special boundary
            r'(?=^||W)' to start of regex. Default True.

         **wordEnd** : bool
            Defines whether the regex should be modified to search at
            end of a word, by adding special boundary r'(?=|W|$)' to
            end of regex. Default True.

      Raises:
         re.error
            If regular expression fails to compile

class fail2ban.server.datetemplate.DatePatternRegex(pattern=None)

   Bases: "fail2ban.server.datetemplate.DateTemplate"

   Date template, with regex/pattern

   Parameters:
      **pattern** : str
         Sets the date templates pattern.

   Attributes:
      "name"
         Name assigned to template.

      "regex"
         Regex used to search for date.

      "pattern"
         The pattern used for regex with strptime "%" time fields.

   -[ Methods ]-

   +------------+--------------------------------------------------------------------------------------------+
   | "getDate"  | Method to return the date for a log line.                                                  |
   | (self,     |                                                                                            |
   | line)      |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+
   | "matchDat  | Check if regex for date matches on a log line.                                             |
   | e"(self,   |                                                                                            |
   | line)      |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+
   | "setRegex  | Sets regex to use for searching for date in log line.                                      |
   | "(self,    |                                                                                            |
   | value)     |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+

   +--------------+------------+
   | **getRegex** |            |
   +--------------+------------+

   getDate(self, line)

      Method to return the date for a log line.

      This uses a custom version of strptime, using the named groups
      from the instances *pattern* property.

      Parameters:
         **line** : str
            Log line, of which the date should be extracted from.

      Returns:
         (float, str)
            Tuple containing a Unix timestamp, and the string of the
            date which was matched and in turned used to calculated
            the timestamp.

   getRegex(self)

   matchDate(self, line)

      Check if regex for date matches on a log line.

   property name

      Name assigned to template.

   property pattern

      The pattern used for regex with strptime "%" time fields.

      This should be a valid regular expression, of which matching
      string will be extracted from the log line. strptime style "%"
      fields will be replaced by appropriate regular expressions, or
      custom regex groups with names as per the strptime fields can
      also be used instead.

   property regex

      Regex used to search for date.

   setRegex(self, value)

      Sets regex to use for searching for date in log line.

      Parameters:
         **regex** : str
            The regex the template will use for searching for a date.

         **wordBegin** : bool
            Defines whether the regex should be modified to search at
            beginning of a word, by adding special boundary
            r'(?=^||W)' to start of regex. Default True.

         **wordEnd** : bool
            Defines whether the regex should be modified to search at
            end of a word, by adding special boundary r'(?=|W|$)' to
            end of regex. Default True.

      Raises:
         re.error
            If regular expression fails to compile

class fail2ban.server.datetemplate.DateTai64n

   Bases: "fail2ban.server.datetemplate.DateTemplate"

   A date template which matches TAI64N formate timestamps.

   Attributes:
      "name"
         Name assigned to template.

      "regex"
         Regex used to search for date.

   -[ Methods ]-

   +------------+--------------------------------------------------------------------------------------------+
   | "getDate"  | Method to return the date for a log line.                                                  |
   | (self,     |                                                                                            |
   | line)      |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+
   | "matchDat  | Check if regex for date matches on a log line.                                             |
   | e"(self,   |                                                                                            |
   | line)      |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+
   | "setRegex  | Sets regex to use for searching for date in log line.                                      |
   | "(self,    |                                                                                            |
   | regex[,    |                                                                                            |
   | wordBegin, |                                                                                            |
   | wordEnd])  |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+

   +--------------+------------+
   | **getRegex** |            |
   +--------------+------------+

   getDate(self, line)

      Method to return the date for a log line.

      Parameters:
         **line** : str
            Log line, of which the date should be extracted from.

      Returns:
         (float, str)
            Tuple containing a Unix timestamp, and the string of the
            date which was matched and in turned used to calculated
            the timestamp.

   getRegex(self)

   matchDate(self, line)

      Check if regex for date matches on a log line.

   property name

      Name assigned to template.

   property regex

      Regex used to search for date.

   setRegex(self, regex, wordBegin=True, wordEnd=True)

      Sets regex to use for searching for date in log line.

      Parameters:
         **regex** : str
            The regex the template will use for searching for a date.

         **wordBegin** : bool
            Defines whether the regex should be modified to search at
            beginning of a word, by adding special boundary
            r'(?=^||W)' to start of regex. Default True.

         **wordEnd** : bool
            Defines whether the regex should be modified to search at
            end of a word, by adding special boundary r'(?=|W|$)' to
            end of regex. Default True.

      Raises:
         re.error
            If regular expression fails to compile

class fail2ban.server.datetemplate.DateTemplate

   Bases: "object"

   A template which searches for and returns a date from a log line.

   This is an not functional abstract class which other templates
   should inherit from.

   Attributes:
      "name"
         Name assigned to template.

      "regex"
         Regex used to search for date.

   -[ Methods ]-

   +------------+--------------------------------------------------------------------------------------------+
   | "getDate"  | Abstract method, which should return the date for a log line                               |
   | (self,     |                                                                                            |
   | line)      |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+
   | "matchDat  | Check if regex for date matches on a log line.                                             |
   | e"(self,   |                                                                                            |
   | line)      |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+
   | "setRegex  | Sets regex to use for searching for date in log line.                                      |
   | "(self,    |                                                                                            |
   | regex[,    |                                                                                            |
   | wordBegin, |                                                                                            |
   | wordEnd])  |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+

   +--------------+------------+
   | **getRegex** |            |
   +--------------+------------+

   abstract getDate(self, line)

      Abstract method, which should return the date for a log line

      This should return the date for a log line, typically taking the
      date from the part of the line which matched the templates
      regex. This requires abstraction, therefore just raises
      exception.

      Parameters:
         **line** : str
            Log line, of which the date should be extracted from.

      Raises:
         NotImplementedError
            Abstract method, therefore always returns this.

   getRegex(self)

   matchDate(self, line)

      Check if regex for date matches on a log line.

   property name

      Name assigned to template.

   property regex

      Regex used to search for date.

   setRegex(self, regex, wordBegin=True, wordEnd=True)

      Sets regex to use for searching for date in log line.

      Parameters:
         **regex** : str
            The regex the template will use for searching for a date.

         **wordBegin** : bool
            Defines whether the regex should be modified to search at
            beginning of a word, by adding special boundary
            r'(?=^||W)' to start of regex. Default True.

         **wordEnd** : bool
            Defines whether the regex should be modified to search at
            end of a word, by adding special boundary r'(?=|W|$)' to
            end of regex. Default True.

      Raises:
         re.error
            If regular expression fails to compile
