diff --git a/fail2ban-client b/fail2ban-client index 612add7ff..fea1c8a62 100755 --- a/fail2ban-client +++ b/fail2ban-client @@ -131,6 +131,14 @@ class Fail2banClient: except ServerExecutionException: logSys.error("Could not start server. Try -x option") return False + elif cmd[0] == "reload" and len(cmd) == 1: + if self.ping(): + self.readConfig() + self.processCmd(['stop', 'all']) + # Configure the server + self.processCmd(self.stream) + else: + logSys.error("Could not find server") else: return self.processCmd([cmd]) diff --git a/server/server.py b/server/server.py index 93157a07e..66a0ce9bc 100644 --- a/server/server.py +++ b/server/server.py @@ -47,8 +47,7 @@ class Server: self.transm.start(force) def quit(self): - for jail in self.jails.copy(): - self.stopJail(jail) + self.stopAllJail() self.transm.stop() def addJail(self, name): @@ -73,6 +72,10 @@ class Server: self.delJail(name) else: raise ServerUnknownJail(name) + + def stopAllJail(self): + for jail in self.jails.copy(): + self.stopJail(jail) def isActive(self, name): if self.jails.has_key(name): diff --git a/server/transmitter.py b/server/transmitter.py index 81977fc6d..5dad10eb0 100644 --- a/server/transmitter.py +++ b/server/transmitter.py @@ -75,6 +75,8 @@ class Transmitter: return "pong" elif action[0] == "add": name = action[1] + if name == "all": + raise Exception("Reserved name") self.server.addJail(name) return name elif action[0] == "start": @@ -84,6 +86,8 @@ class Transmitter: elif action[0] == "stop": if len(action) == 1: self.server.quit() + elif action[1] == "all": + self.server.stopAllJail() else: name = action[1] self.server.stopJail(name)