Browse Source

- Added a "reload" option which reload the configuration

- Added "stop all" which stop all jails but do not exit

git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@277 a942ae1a-1317-0410-a47c-b1dcaea8d605
0.x
Cyril Jaquier 19 years ago
parent
commit
64ddab56c8
  1. 8
      fail2ban-client
  2. 7
      server/server.py
  3. 4
      server/transmitter.py

8
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])

7
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):

4
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)

Loading…
Cancel
Save