mirror of https://github.com/fail2ban/fail2ban
amend to gh-1792: introduced new fail2ban-regex option "--timezone" ("--TZ"), to set time-zone used by convert of time format.
parent
2fe1479484
commit
9a42ce12f4
|
@ -127,6 +127,8 @@ Report bugs to https://github.com/fail2ban/fail2ban/issues
|
||||||
help="set alternate config directory"),
|
help="set alternate config directory"),
|
||||||
Option("-d", "--datepattern",
|
Option("-d", "--datepattern",
|
||||||
help="set custom pattern used to match date/times"),
|
help="set custom pattern used to match date/times"),
|
||||||
|
Option("--timezone", "--TZ", action='store', default=None,
|
||||||
|
help="set time-zone used by convert time format"),
|
||||||
Option("-e", "--encoding", default=PREFER_ENC,
|
Option("-e", "--encoding", default=PREFER_ENC,
|
||||||
help="File encoding. Default: system locale"),
|
help="File encoding. Default: system locale"),
|
||||||
Option("-r", "--raw", action='store_true', default=False,
|
Option("-r", "--raw", action='store_true', default=False,
|
||||||
|
@ -243,6 +245,8 @@ class Fail2banRegex(object):
|
||||||
self._maxlines = 20
|
self._maxlines = 20
|
||||||
if opts.journalmatch is not None:
|
if opts.journalmatch is not None:
|
||||||
self.setJournalMatch(shlex.split(opts.journalmatch))
|
self.setJournalMatch(shlex.split(opts.journalmatch))
|
||||||
|
if opts.timezone:
|
||||||
|
self._filter.setLogTimeZone(opts.timezone)
|
||||||
if opts.datepattern:
|
if opts.datepattern:
|
||||||
self.setDatePattern(opts.datepattern)
|
self.setDatePattern(opts.datepattern)
|
||||||
if opts.usedns:
|
if opts.usedns:
|
||||||
|
|
|
@ -195,6 +195,7 @@ class Fail2banRegexTest(LogCaptureTestCase):
|
||||||
def testVerbose(self):
|
def testVerbose(self):
|
||||||
(opts, args, fail2banRegex) = _Fail2banRegex(
|
(opts, args, fail2banRegex) = _Fail2banRegex(
|
||||||
"--datepattern", "^(?:%a )?%b %d %H:%M:%S(?:\.%f)?(?: %ExY)?",
|
"--datepattern", "^(?:%a )?%b %d %H:%M:%S(?:\.%f)?(?: %ExY)?",
|
||||||
|
"--timezone", "UTC+0200",
|
||||||
"--verbose", "--verbose-date", "--print-no-missed",
|
"--verbose", "--verbose-date", "--print-no-missed",
|
||||||
Fail2banRegexTest.FILENAME_02,
|
Fail2banRegexTest.FILENAME_02,
|
||||||
Fail2banRegexTest.RE_00
|
Fail2banRegexTest.RE_00
|
||||||
|
|
Loading…
Reference in New Issue