From 0148b1c9b4350721090a6d4a9102b5fc7337ffbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= Date: Fri, 22 Mar 2024 09:21:36 +0100 Subject: [PATCH 1/2] Fix typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: François Cami --- kdcproxy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kdcproxy/__init__.py b/kdcproxy/__init__.py index 1493b30..a44c29a 100644 --- a/kdcproxy/__init__.py +++ b/kdcproxy/__init__.py @@ -101,7 +101,7 @@ def __await_reply(self, pr, rsocks, wsocks, timeout): sock.sendall(pr.request) extra = 10 # New connections get 10 extra seconds except Exception as e: - logging.warning("Conection broken while writing (%s)", e) + logging.warning("Connection broken while writing (%s)", e) continue rsocks.append(sock) wsocks.remove(sock) From 54ccbb862ea7118d693ec9b9f7929e6d441f1521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= Date: Fri, 22 Mar 2024 09:32:41 +0100 Subject: [PATCH 2/2] Prefix all logging messages with "kdcproxy:" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When running kdcproxy in mod_wsgi, it is unclear from which component error messages come from. For example: mod_wsgi.c(): [client WARNING:root:Connection broken while writing (...) Prefixing all logging messages with "kdcproxy:" solves this. Signed-off-by: François Cami --- kdcproxy/__init__.py | 6 ++++-- kdcproxy/config/__init__.py | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/kdcproxy/__init__.py b/kdcproxy/__init__.py index a44c29a..1acc91c 100644 --- a/kdcproxy/__init__.py +++ b/kdcproxy/__init__.py @@ -101,7 +101,8 @@ def __await_reply(self, pr, rsocks, wsocks, timeout): sock.sendall(pr.request) extra = 10 # New connections get 10 extra seconds except Exception as e: - logging.warning("Connection broken while writing (%s)", e) + logging.warning( + "kdcproxy: Connection broken while writing (%s)", e) continue rsocks.append(sock) wsocks.remove(sock) @@ -110,7 +111,8 @@ def __await_reply(self, pr, rsocks, wsocks, timeout): try: reply = self.__handle_recv(sock, read_buffers) except Exception as e: - logging.warning("Connection broken while reading (%s)", e) + logging.warning( + "kdcproxy: Connection broken while reading (%s)", e) if self.sock_type(sock) == socket.SOCK_STREAM: # Remove broken TCP socket from readers rsocks.remove(sock) diff --git a/kdcproxy/config/__init__.py b/kdcproxy/config/__init__.py index a1435b7..377907d 100644 --- a/kdcproxy/config/__init__.py +++ b/kdcproxy/config/__init__.py @@ -60,14 +60,16 @@ def __init__(self, filenames=None): try: self.__cp.read(filenames) except configparser.Error: - logging.error("Unable to read config file(s): %s", filenames) + logging.error("kdcproxy: Unable to read config file(s): %s", + filenames) try: mod = self.__cp.get(self.GLOBAL, "configs") try: importlib.import_module("kdcproxy.config." + mod) except ImportError as e: - logging.log(logging.ERROR, "Error reading config: %s" % e) + logging.log(logging.ERROR, + "kdcproxy: Error reading config: %s" % e) except configparser.Error: pass @@ -134,7 +136,7 @@ def __init__(self): except Exception as e: fmt = (allsub[i], repr(e)) logging.log(logging.WARNING, - "Error instantiating %s due to %s" % fmt) + "kdcproxy: Error instantiating %s due to %s" % fmt) assert self.__resolvers # See if we should use DNS