mirror of https://github.com/fail2ban/fail2ban
- The options have a specified type now
git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@65 a942ae1a-1317-0410-a47c-b1dcaea8d6050.6
parent
78b32ef3b2
commit
7b13c386f9
|
@ -34,7 +34,9 @@ class ConfigReader:
|
||||||
Fail2Ban. Each other section is for a different log file.
|
Fail2Ban. Each other section is for a different log file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
optionValues = ("logfile", "timeregex", "timepattern", "failregex")
|
optionValues = (["bool", "enabled"], ["str", "logfile"],
|
||||||
|
["str", "timeregex"], ["str", "timepattern"],
|
||||||
|
["str", "failregex"])
|
||||||
|
|
||||||
def __init__(self, logSys, confPath):
|
def __init__(self, logSys, confPath):
|
||||||
self.confPath = confPath
|
self.confPath = confPath
|
||||||
|
@ -59,8 +61,14 @@ class ConfigReader:
|
||||||
values = dict()
|
values = dict()
|
||||||
for option in self.optionValues:
|
for option in self.optionValues:
|
||||||
try:
|
try:
|
||||||
v = self.configParser.get(sec, option)
|
if option[0] == "bool":
|
||||||
values[option] = v
|
v = self.configParser.getboolean(sec, option[1])
|
||||||
|
elif option[0] == "int":
|
||||||
|
v = self.configParser.getint(sec, option[1])
|
||||||
|
else:
|
||||||
|
v = self.configParser.get(sec, option[1])
|
||||||
|
|
||||||
|
values[option[1]] = v
|
||||||
except NoOptionError:
|
except NoOptionError:
|
||||||
self.logSys.info("No "+option+" defined in "+sec)
|
self.logSys.info("No "+option+" defined in "+sec)
|
||||||
return values
|
return values
|
||||||
|
|
Loading…
Reference in New Issue