[Openvpn-devel,2/2] Add debug output for sent IV variables in client mode with verb 7

Message ID 20230210142712.572303-5-arne@rfc2549.org
State Rejected
Headers show
Series None | expand

Commit Message

Arne Schwabe Feb. 10, 2023, 2:27 p.m. UTC
This helps debugging what information a client is sending without having to
use a debugger or to look at the server log.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
 src/openvpn/ssl.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Patch

diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c
index 016bdc57f..1138dc4e7 100644
--- a/src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c
@@ -1970,6 +1970,20 @@  read_string_alloc(struct buffer *buf)
     return str;
 }
 
+static void
+print_client_peer_info(struct buffer *out, struct gc_arena *gc)
+{
+    struct buffer buf = alloc_buf_gc(buf_len(out), gc);
+    buf_copy(&buf, out);
+
+    char line[256];
+
+    while (buf_parse(&buf, '\n', line, sizeof(line)))
+    {
+        chomp(line);
+        msg(D_PUSH_DEBUG, "sending peer info: %s", line);
+    }
+}
 /**
  * Prepares the IV_ and UV_ variables that are part of the
  * exchange to signal the peer's capabilities. The amount
@@ -2119,6 +2133,11 @@  push_peer_info(struct buffer *buf, struct tls_session *session)
             }
         }
 
+        if (check_debug_level(D_PUSH_DEBUG))
+        {
+            print_client_peer_info(&out, &gc);
+        }
+
         if (!write_string(buf, BSTR(&out), -1))
         {
             goto error;