mirror of https://github.com/fail2ban/fail2ban
- Added "socket" option in "fail2ban.conf"
git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@407 a942ae1a-1317-0410-a47c-b1dcaea8d6050.x
parent
7989e66270
commit
c8fdabf001
|
@ -12,7 +12,8 @@ ver. 0.7.4 (2006/09/28) - beta
|
|||
- Improved configuration files. Thanks to Yaroslav Halchenko
|
||||
- Added man page for "fail2ban-regex"
|
||||
- Moved ban/unban messages from "info" level to "warn"
|
||||
- Added "-s" option to specify the socket path
|
||||
- Added "-s" option to specify the socket path and "socket"
|
||||
option in "fail2ban.conf"
|
||||
|
||||
ver. 0.7.3 (2006/09/28) - beta
|
||||
----------
|
||||
|
|
|
@ -46,9 +46,15 @@ class Configurator:
|
|||
def getBaseDir(self):
|
||||
return ConfigReader.getBaseDir()
|
||||
|
||||
def readAll(self):
|
||||
def readEarly(self):
|
||||
self.__fail2ban.read()
|
||||
|
||||
def readAll(self):
|
||||
self.readEarly()
|
||||
self.__jails.read()
|
||||
|
||||
def getEarlyOptions(self):
|
||||
return self.__fail2ban.getEarlyOptions()
|
||||
|
||||
def getAllOptions(self):
|
||||
self.__settings["general"] = self.__fail2ban.getOptions()
|
||||
|
|
|
@ -38,6 +38,10 @@ class Fail2banReader(ConfigReader):
|
|||
def read(self):
|
||||
ConfigReader.read(self, "fail2ban")
|
||||
|
||||
def getEarlyOptions(self):
|
||||
opts = [["string", "socket", "/tmp/fail2ban.sock"]]
|
||||
return ConfigReader.getOptions(self, "Definition", opts)
|
||||
|
||||
def getOptions(self):
|
||||
opts = [["int", "loglevel", 1],
|
||||
["string", "logtarget", "STDERR"]]
|
||||
|
|
|
@ -52,13 +52,14 @@ class Fail2banClient:
|
|||
def __init__(self):
|
||||
self.__argv = None
|
||||
self.__stream = None
|
||||
self.__configurator = Configurator()
|
||||
self.__conf = dict()
|
||||
self.__conf["conf"] = "/etc/fail2ban"
|
||||
self.__conf["dump"] = False
|
||||
self.__conf["force"] = False
|
||||
self.__conf["verbose"] = 2
|
||||
self.__conf["interactive"] = False
|
||||
self.__conf["socket"] = "/tmp/fail2ban.sock"
|
||||
self.__conf["socket"] = None
|
||||
|
||||
def dispVersion(self):
|
||||
print "Fail2Ban v" + version
|
||||
|
@ -273,6 +274,16 @@ class Fail2banClient:
|
|||
stdout.setFormatter(formatter)
|
||||
logSys.addHandler(stdout)
|
||||
|
||||
# Set the configuration path
|
||||
self.__configurator.setBaseDir(self.__conf["conf"])
|
||||
|
||||
# Set socket path
|
||||
self.__configurator.readEarly()
|
||||
socket = self.__configurator.getEarlyOptions()
|
||||
if self.__conf["socket"] == None:
|
||||
self.__conf["socket"] = socket["socket"]
|
||||
logSys.warn("Using socket file " + self.__conf["socket"])
|
||||
|
||||
if self.__conf["dump"]:
|
||||
self.__readConfig()
|
||||
self.dumpConfig(self.__stream)
|
||||
|
@ -306,12 +317,10 @@ class Fail2banClient:
|
|||
|
||||
def __readConfig(self):
|
||||
# Read the configuration
|
||||
cfg = Configurator()
|
||||
cfg.setBaseDir(self.__conf["conf"])
|
||||
cfg.readAll()
|
||||
cfg.getAllOptions()
|
||||
cfg.convertToProtocol()
|
||||
self.__stream = cfg.getConfigStream()
|
||||
self.__configurator.readAll()
|
||||
self.__configurator.getAllOptions()
|
||||
self.__configurator.convertToProtocol()
|
||||
self.__stream = self.__configurator.getConfigStream()
|
||||
|
||||
@staticmethod
|
||||
def dumpConfig(cmd):
|
||||
|
|
Loading…
Reference in New Issue