mirror of https://github.com/fail2ban/fail2ban
Merge branch '0.10' into 0.11
commit
47d3a1213c
|
@ -67,6 +67,8 @@ ver. 0.10.4-dev-1 (20??/??/??) - development edition
|
||||||
### New Features
|
### New Features
|
||||||
|
|
||||||
### Enhancements
|
### Enhancements
|
||||||
|
* since v.0.10.4, fail2ban-client, fail2ban-server and fail2ban-regex will return version without logo info,
|
||||||
|
additionally option `-V` can be used to get version in normalized machine-readable short format.
|
||||||
|
|
||||||
|
|
||||||
ver. 0.10.3 (2018/04/04) - the-time-is-always-right-to-do-what-is-right
|
ver. 0.10.3 (2018/04/04) - the-time-is-always-right-to-do-what-is-right
|
||||||
|
|
|
@ -25,7 +25,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ..version import version
|
from ..version import version, normVersion
|
||||||
from ..protocol import printFormatted
|
from ..protocol import printFormatted
|
||||||
from ..helpers import getLogger, str2LogLevel, getVerbosityFormat
|
from ..helpers import getLogger, str2LogLevel, getVerbosityFormat
|
||||||
|
|
||||||
|
@ -78,12 +78,11 @@ class Fail2banCmdLine():
|
||||||
for o in obj.__dict__:
|
for o in obj.__dict__:
|
||||||
self.__dict__[o] = obj.__dict__[o]
|
self.__dict__[o] = obj.__dict__[o]
|
||||||
|
|
||||||
def dispVersion(self):
|
def dispVersion(self, short=False):
|
||||||
output("Fail2Ban v" + version)
|
if not short:
|
||||||
output("")
|
output("Fail2Ban v" + version)
|
||||||
output("Copyright (c) 2004-2008 Cyril Jaquier, 2008- Fail2Ban Contributors")
|
else:
|
||||||
output("Copyright of modifications held by their respective authors.")
|
output(normVersion())
|
||||||
output("Licensed under the GNU General Public License v2 (GPL).")
|
|
||||||
|
|
||||||
def dispUsage(self):
|
def dispUsage(self):
|
||||||
""" Prints Fail2Ban command line options and exits
|
""" Prints Fail2Ban command line options and exits
|
||||||
|
@ -114,7 +113,7 @@ class Fail2banCmdLine():
|
||||||
output(" --timeout timeout to wait for the server (for internal usage only, don't read configuration)")
|
output(" --timeout timeout to wait for the server (for internal usage only, don't read configuration)")
|
||||||
output(" --str2sec <STRING> convert time abbreviation format to seconds")
|
output(" --str2sec <STRING> convert time abbreviation format to seconds")
|
||||||
output(" -h, --help display this help message")
|
output(" -h, --help display this help message")
|
||||||
output(" -V, --version print the version")
|
output(" -V, --version print the version (-V returns machine-readable short format)")
|
||||||
|
|
||||||
if not caller.endswith('server'):
|
if not caller.endswith('server'):
|
||||||
output("")
|
output("")
|
||||||
|
@ -168,7 +167,7 @@ class Fail2banCmdLine():
|
||||||
self.dispUsage()
|
self.dispUsage()
|
||||||
return True
|
return True
|
||||||
elif o in ["-V", "--version"]:
|
elif o in ["-V", "--version"]:
|
||||||
self.dispVersion()
|
self.dispVersion(o == "-V")
|
||||||
return True
|
return True
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ try: # pragma: no cover
|
||||||
except ImportError:
|
except ImportError:
|
||||||
FilterSystemd = None
|
FilterSystemd = None
|
||||||
|
|
||||||
from ..version import version
|
from ..version import version, normVersion
|
||||||
from .filterreader import FilterReader
|
from .filterreader import FilterReader
|
||||||
from ..server.filter import Filter, FileContainer
|
from ..server.filter import Filter, FileContainer
|
||||||
from ..server.failregex import Regex, RegexException
|
from ..server.failregex import Regex, RegexException
|
||||||
|
@ -93,6 +93,10 @@ def journal_lines_gen(flt, myjournal): # pragma: no cover
|
||||||
break
|
break
|
||||||
yield flt.formatJournalEntry(entry)
|
yield flt.formatJournalEntry(entry)
|
||||||
|
|
||||||
|
def dumpNormVersion(*args):
|
||||||
|
output(normVersion())
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
def get_opt_parser():
|
def get_opt_parser():
|
||||||
# use module docstring for help output
|
# use module docstring for help output
|
||||||
p = OptionParser(
|
p = OptionParser(
|
||||||
|
@ -145,6 +149,8 @@ Report bugs to https://github.com/fail2ban/fail2ban/issues
|
||||||
dest="log_level",
|
dest="log_level",
|
||||||
default='critical',
|
default='critical',
|
||||||
help="Log level for the Fail2Ban logger to use"),
|
help="Log level for the Fail2Ban logger to use"),
|
||||||
|
Option('-V', action="callback", callback=dumpNormVersion,
|
||||||
|
help="get version in machine-readable short format"),
|
||||||
Option('-v', '--verbose', action="count", dest="verbose",
|
Option('-v', '--verbose', action="count", dest="verbose",
|
||||||
default=0,
|
default=0,
|
||||||
help="Increase verbosity"),
|
help="Increase verbosity"),
|
||||||
|
|
|
@ -227,7 +227,7 @@ class JailReader(ConfigReader):
|
||||||
path, tail = path if len(path) > 1 else (path[0], "head")
|
path, tail = path if len(path) > 1 else (path[0], "head")
|
||||||
pathList = JailReader._glob(path)
|
pathList = JailReader._glob(path)
|
||||||
if len(pathList) == 0:
|
if len(pathList) == 0:
|
||||||
logSys.error("No file(s) found for glob %s" % path)
|
logSys.notice("No file(s) found for glob %s" % path)
|
||||||
for p in pathList:
|
for p in pathList:
|
||||||
found_files += 1
|
found_files += 1
|
||||||
stream.append(
|
stream.append(
|
||||||
|
|
|
@ -483,7 +483,10 @@ class Fail2banClientTest(Fail2banClientServerBase):
|
||||||
self.assertLogged("Usage: " + CLIENT)
|
self.assertLogged("Usage: " + CLIENT)
|
||||||
self.assertLogged("Report bugs to ")
|
self.assertLogged("Report bugs to ")
|
||||||
self.pruneLog()
|
self.pruneLog()
|
||||||
self.execCmd(SUCCESS, (), "-vq", "-V")
|
self.execCmd(SUCCESS, (), "-V")
|
||||||
|
self.assertLogged(fail2bancmdline.normVersion())
|
||||||
|
self.pruneLog()
|
||||||
|
self.execCmd(SUCCESS, (), "-vq", "--version")
|
||||||
self.assertLogged("Fail2Ban v" + fail2bancmdline.version)
|
self.assertLogged("Fail2Ban v" + fail2bancmdline.version)
|
||||||
self.pruneLog()
|
self.pruneLog()
|
||||||
self.execCmd(SUCCESS, (), "--str2sec", "1d12h30m")
|
self.execCmd(SUCCESS, (), "--str2sec", "1d12h30m")
|
||||||
|
|
|
@ -347,6 +347,11 @@ class Fail2banRegexTest(LogCaptureTestCase):
|
||||||
|
|
||||||
def testExecCmdLine_Usage(self):
|
def testExecCmdLine_Usage(self):
|
||||||
self.assertNotEqual(_test_exec_command_line(), 0)
|
self.assertNotEqual(_test_exec_command_line(), 0)
|
||||||
|
self.pruneLog()
|
||||||
|
self.assertEqual(_test_exec_command_line('-V'), 0)
|
||||||
|
self.assertLogged(fail2banregex.normVersion())
|
||||||
|
self.pruneLog()
|
||||||
|
self.assertEqual(_test_exec_command_line('--version'), 0)
|
||||||
|
|
||||||
def testExecCmdLine_Direct(self):
|
def testExecCmdLine_Direct(self):
|
||||||
self.assertEqual(_test_exec_command_line(
|
self.assertEqual(_test_exec_command_line(
|
||||||
|
|
|
@ -25,3 +25,7 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2005-2016 Yaroslav Halchenko,
|
||||||
__license__ = "GPL-v2+"
|
__license__ = "GPL-v2+"
|
||||||
|
|
||||||
version = "0.11.0.dev2"
|
version = "0.11.0.dev2"
|
||||||
|
|
||||||
|
def normVersion():
|
||||||
|
""" Returns fail2ban version in normalized machine-readable format"""
|
||||||
|
return version.replace('.fix', '').replace('.dev', '.')
|
||||||
|
|
Loading…
Reference in New Issue