diff --git a/fail2ban/server/server.py b/fail2ban/server/server.py index 7edf19e9..60eea1f3 100644 --- a/fail2ban/server/server.py +++ b/fail2ban/server/server.py @@ -60,7 +60,7 @@ def _thread_name(): class Server: - def __init__(self, daemon = False): + def __init__(self, daemon=False): self.__loggingLock = Lock() self.__lock = RLock() self.__jails = Jails() @@ -377,7 +377,7 @@ class Server: return self.__jails[name].actions.getBanTime() def isStarted(self): - self.__asyncServer.isActive() + return self.__asyncServer is not None and self.__asyncServer.isActive() def isAlive(self, jailnum=None): if jailnum is not None and len(self.__jails) != jailnum: diff --git a/fail2ban/tests/servertestcase.py b/fail2ban/tests/servertestcase.py index 9fc62acd..d733da0a 100644 --- a/fail2ban/tests/servertestcase.py +++ b/fail2ban/tests/servertestcase.py @@ -158,6 +158,9 @@ class Transmitter(TransmitterBase): def setUp(self): self.server = TestServer() super(Transmitter, self).setUp() + # so far isStarted only tested but not used otherwise + # and here we don't really .start server + self.assertFalse(self.server.isStarted()) def testStopServer(self): self.assertEqual(self.transm.proceed(["stop"]), (0, None)) @@ -1004,6 +1007,7 @@ class LoggingTests(LogCaptureTestCase): server = TestServer() try: server.start(sock_name, pidfile_name, force=False) + self.assertFalse(server.isStarted()) self.assertLogged("Server already running") finally: server.quit()