mirror of https://github.com/fail2ban/fail2ban
ENH: Rename splitAction to extractOptions in jailreader
parent
c95b87c13c
commit
1a43a0bce1
|
@ -77,7 +77,7 @@ class JailReader(ConfigReader):
|
||||||
|
|
||||||
if self.isEnabled():
|
if self.isEnabled():
|
||||||
# Read filter
|
# Read filter
|
||||||
filterName, filterOpt = JailReader.splitOption(
|
filterName, filterOpt = JailReader.extractOptions(
|
||||||
self.__opts["filter"])
|
self.__opts["filter"])
|
||||||
self.__filter = FilterReader(
|
self.__filter = FilterReader(
|
||||||
filterName, self.__name, filterOpt, basedir=self.getBaseDir())
|
filterName, self.__name, filterOpt, basedir=self.getBaseDir())
|
||||||
|
@ -93,7 +93,7 @@ class JailReader(ConfigReader):
|
||||||
try:
|
try:
|
||||||
if not act: # skip empty actions
|
if not act: # skip empty actions
|
||||||
continue
|
continue
|
||||||
actName, actOpt = JailReader.splitOption(act)
|
actName, actOpt = JailReader.extractOptions(act)
|
||||||
action = ActionReader(
|
action = ActionReader(
|
||||||
actName, self.__name, actOpt, basedir=self.getBaseDir())
|
actName, self.__name, actOpt, basedir=self.getBaseDir())
|
||||||
ret = action.read()
|
ret = action.read()
|
||||||
|
@ -151,7 +151,7 @@ class JailReader(ConfigReader):
|
||||||
return stream
|
return stream
|
||||||
|
|
||||||
#@staticmethod
|
#@staticmethod
|
||||||
def splitOption(option):
|
def extractOptions(option):
|
||||||
m = JailReader.optionCRE.match(option)
|
m = JailReader.optionCRE.match(option)
|
||||||
d = dict()
|
d = dict()
|
||||||
mgroups = m.groups()
|
mgroups = m.groups()
|
||||||
|
@ -194,4 +194,4 @@ class JailReader(ConfigReader):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
logSys.error("Invalid argument %s in '%s'" % (p, option_opts))
|
logSys.error("Invalid argument %s in '%s'" % (p, option_opts))
|
||||||
return [option_name, d]
|
return [option_name, d]
|
||||||
splitOption = staticmethod(splitOption)
|
extractOptions = staticmethod(extractOptions)
|
||||||
|
|
|
@ -115,7 +115,7 @@ class JailReaderTest(unittest.TestCase):
|
||||||
def testSplitOption(self):
|
def testSplitOption(self):
|
||||||
action = "mail-whois[name=SSH]"
|
action = "mail-whois[name=SSH]"
|
||||||
expected = ['mail-whois', {'name': 'SSH'}]
|
expected = ['mail-whois', {'name': 'SSH'}]
|
||||||
result = JailReader.splitOption(action)
|
result = JailReader.extractOptions(action)
|
||||||
self.assertEquals(expected, result)
|
self.assertEquals(expected, result)
|
||||||
|
|
||||||
class FilterReaderTest(unittest.TestCase):
|
class FilterReaderTest(unittest.TestCase):
|
||||||
|
|
Loading…
Reference in New Issue