mirror of https://github.com/fail2ban/fail2ban
- Made configreader more generic. Also used for global options now
git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_5@118 a942ae1a-1317-0410-a47c-b1dcaea8d6050.5
parent
1014183f3f
commit
65fef83e56
|
@ -37,18 +37,6 @@ class ConfigReader:
|
||||||
Fail2Ban. Each other section is for a different log file.
|
Fail2Ban. Each other section is for a different log file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Each optionValues entry is composed of an array with:
|
|
||||||
# 0 -> the type of the option
|
|
||||||
# 1 -> the name of the option
|
|
||||||
# 2 -> the default value for the option
|
|
||||||
optionValues = (["bool", "enabled", True],
|
|
||||||
["str", "logfile", "/dev/null"],
|
|
||||||
["str", "timeregex", ""],
|
|
||||||
["str", "timepattern", ""],
|
|
||||||
["str", "failregex", ""],
|
|
||||||
["str", "fwbanrule", ""],
|
|
||||||
["str", "fwunbanrule", ""])
|
|
||||||
|
|
||||||
def __init__(self, confPath):
|
def __init__(self, confPath):
|
||||||
self.confPath = confPath
|
self.confPath = confPath
|
||||||
self.configParser = SafeConfigParser()
|
self.configParser = SafeConfigParser()
|
||||||
|
@ -64,12 +52,16 @@ class ConfigReader:
|
||||||
"""
|
"""
|
||||||
return self.configParser.sections()
|
return self.configParser.sections()
|
||||||
|
|
||||||
def getLogOptions(self, sec):
|
# Each optionValues entry is composed of an array with:
|
||||||
|
# 0 -> the type of the option
|
||||||
|
# 1 -> the name of the option
|
||||||
|
# 2 -> the default value for the option
|
||||||
|
def getLogOptions(self, sec, options):
|
||||||
""" Gets all the options of a given section. The options
|
""" Gets all the options of a given section. The options
|
||||||
are defined in the optionValues list.
|
are defined in the optionValues list.
|
||||||
"""
|
"""
|
||||||
values = dict()
|
values = dict()
|
||||||
for option in self.optionValues:
|
for option in options:
|
||||||
try:
|
try:
|
||||||
if option[0] == "bool":
|
if option[0] == "bool":
|
||||||
v = self.configParser.getboolean(sec, option[1])
|
v = self.configParser.getboolean(sec, option[1])
|
||||||
|
|
Loading…
Reference in New Issue