From 5b63ad17c674084a9dd796065307bdda13327625 Mon Sep 17 00:00:00 2001 From: sebres Date: Mon, 5 Mar 2018 21:54:18 +0100 Subject: [PATCH] stability of the test-cases: avoid echoing of server-ready in configure thread, if heavy-debug (only answer from new internal command "server-status"). --- fail2ban/client/fail2banclient.py | 6 +++--- fail2ban/server/transmitter.py | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fail2ban/client/fail2banclient.py b/fail2ban/client/fail2banclient.py index 13ebcdef..f80193ee 100755 --- a/fail2ban/client/fail2banclient.py +++ b/fail2ban/client/fail2banclient.py @@ -99,7 +99,7 @@ class Fail2banClient(Fail2banCmdLine, Thread): ret = client.send(c) if ret[0] == 0: logSys.log(5, "OK : %r", ret[1]) - if showRet or c[0] == 'echo': + if showRet or c[0] in ('echo', 'server-status'): output(beautifier.beautify(ret[1])) else: logSys.error("NOK: %r", ret[1].args) @@ -128,7 +128,7 @@ class Fail2banClient(Fail2banCmdLine, Thread): except Exception as e: # pragma: no cover if showRet or self._conf["verbose"] > 1: logSys.debug(e) - if showRet or c[0] == 'echo': + if showRet or c[0] in ('echo', 'server-status'): sys.stdout.flush() return streamRet @@ -186,7 +186,7 @@ class Fail2banClient(Fail2banCmdLine, Thread): logSys.error("Fail2ban seems to be in unexpected state (not running but the socket exists)") return None - stream.append(['echo', 'Server ready']) + stream.append(['server-status']) return stream ## diff --git a/fail2ban/server/transmitter.py b/fail2ban/server/transmitter.py index ecc2a138..1aa7f3e2 100644 --- a/fail2ban/server/transmitter.py +++ b/fail2ban/server/transmitter.py @@ -115,6 +115,9 @@ class Transmitter: return cnt elif command[0] == "echo": return command[1:] + elif command[0] == "server-status": + logSys.debug("Server ready") + return "Server ready" elif command[0] == "sleep": value = command[1] time.sleep(float(value))