- 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-b1dcaea8d605
0.5
Cyril Jaquier 2005-07-07 16:51:52 +00:00
parent 1014183f3f
commit 65fef83e56
1 changed files with 8 additions and 16 deletions

View File

@ -36,19 +36,7 @@ class ConfigReader:
The DEFAULT section contains the global information about
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):
self.confPath = confPath
self.configParser = SafeConfigParser()
@ -63,13 +51,17 @@ class ConfigReader:
file except the DEFAULT section.
"""
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
are defined in the optionValues list.
"""
values = dict()
for option in self.optionValues:
for option in options:
try:
if option[0] == "bool":
v = self.configParser.getboolean(sec, option[1])