From 9c61adcad72e81d0c9471daad8d5cd84efa48eb5 Mon Sep 17 00:00:00 2001 From: Steven Hiscocks Date: Tue, 24 Sep 2013 22:11:04 +0100 Subject: [PATCH] ENH+DOC: Allow setting of Epoch and TAI64N date pattern Also add this to jail.conf man page --- fail2ban/server/filter.py | 10 ++++++++-- man/jail.conf.5 | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fail2ban/server/filter.py b/fail2ban/server/filter.py index e1f8613f..7d1bcbaf 100644 --- a/fail2ban/server/filter.py +++ b/fail2ban/server/filter.py @@ -28,7 +28,7 @@ from failmanager import FailManager from ticket import FailTicket from jailthread import JailThread from datedetector import DateDetector -from datetemplate import DatePatternRegex, DateISO8601 +from datetemplate import DatePatternRegex, DateISO8601, DateEpoch, DateTai64n from mytime import MyTime from failregex import FailRegex, Regex, RegexException @@ -199,9 +199,15 @@ class Filter(JailThread): def setDatePattern(self, pattern): dateDetector = DateDetector() - if pattern == "ISO8601": + if pattern.upper() == "ISO8601": template = DateISO8601() template.setName("ISO8601") + elif pattern.upper() == "EPOCH": + template = DateEpoch() + template.setName("Epoch") + elif patter.upper() == "TAI64N": + template = DateTai64n() + template.setName("TAI64N") else: template = DatePatternRegex() if pattern[0] == "^": # Special extra to enable anchor diff --git a/man/jail.conf.5 b/man/jail.conf.5 index 668530cd..ffad71d5 100644 --- a/man/jail.conf.5 +++ b/man/jail.conf.5 @@ -183,6 +183,9 @@ The following are acceptable format fields (see strptime(3) for descriptions): .nf %% %a %A %b %B %d %H %I %j %m %M %p %S %U %w %W %y %Y .fi +.br + +Also, special values of \fIEpoch\fR (UNIX Timestamp), \fITAI64N\fR and \fIISO8601\fR can be used. .TP \fBjournalmatch\fR specifies the systemd journal match used to filter the journal entries. See \fBjournalctl(1)\fR and \fBsystemd.journal-fields(7)\fR for matches syntax and more details on special journal fields. This option is only valid for the \fIsystemd\fR backend.