From bbed90cee5c9c60f02c02896a68d62e63dd2887a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 16 Feb 2026 08:15:51 +0300 Subject: [PATCH] Debug: Enable crypto packet dumps conditionally based on debug level --- Makefile | 52 +++++++++++++++++++++--------------------- src/etcp_connections.c | 10 ++++---- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index e9453bde1..eb4df3ac0 100644 --- a/Makefile +++ b/Makefile @@ -89,8 +89,8 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : -build_triplet = x86_64-w64-mingw32 -host_triplet = x86_64-w64-mingw32 +build_triplet = x86_64-pc-linux-gnu +host_triplet = x86_64-pc-linux-gnu subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac @@ -210,28 +210,28 @@ distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print -ACLOCAL = ${SHELL} '/c/ARM/_uTun/utun2/build-aux/missing' aclocal-1.16 +ACLOCAL = ${SHELL} '/home/vnc1/proj/utun3/build-aux/missing' aclocal-1.16 AMTAR = $${TAR-tar} AM_DEFAULT_VERBOSITY = 1 AR = ar -AUTOCONF = ${SHELL} '/c/ARM/_uTun/utun2/build-aux/missing' autoconf -AUTOHEADER = ${SHELL} '/c/ARM/_uTun/utun2/build-aux/missing' autoheader -AUTOMAKE = ${SHELL} '/c/ARM/_uTun/utun2/build-aux/missing' automake-1.16 -AWK = gawk -CC = x86_64-w64-mingw32-gcc +AUTOCONF = ${SHELL} '/home/vnc1/proj/utun3/build-aux/missing' autoconf +AUTOHEADER = ${SHELL} '/home/vnc1/proj/utun3/build-aux/missing' autoheader +AUTOMAKE = ${SHELL} '/home/vnc1/proj/utun3/build-aux/missing' automake-1.16 +AWK = mawk +CC = gcc CCDEPMODE = depmode=gcc3 CFLAGS = -g -O2 CPPFLAGS = CSCOPE = cscope CTAGS = ctags -CYGPATH_W = cygpath -w +CYGPATH_W = echo DEFS = -DHAVE_CONFIG_H DEPDIR = .deps ECHO_C = ECHO_N = -n ECHO_T = ETAGS = etags -EXEEXT = .exe +EXEEXT = INSTALL = /usr/bin/install -c INSTALL_DATA = ${INSTALL} -m 644 INSTALL_PROGRAM = ${INSTALL} @@ -241,7 +241,7 @@ LDFLAGS = LIBOBJS = LIBS = -lcrypto LTLIBOBJS = -MAKEINFO = ${SHELL} '/c/ARM/_uTun/utun2/build-aux/missing' makeinfo +MAKEINFO = ${SHELL} '/home/vnc1/proj/utun3/build-aux/missing' makeinfo MKDIR_P = /usr/bin/mkdir -p OBJEXT = o PACKAGE = utun @@ -254,41 +254,41 @@ PACKAGE_VERSION = 2.0.0 PATH_SEPARATOR = : RANLIB = ranlib SET_MAKE = -SHELL = /bin/sh +SHELL = /bin/bash STRIP = VERSION = 2.0.0 -abs_builddir = /c/ARM/_uTun/utun2 -abs_srcdir = /c/ARM/_uTun/utun2 -abs_top_builddir = /c/ARM/_uTun/utun2 -abs_top_srcdir = /c/ARM/_uTun/utun2 +abs_builddir = /home/vnc1/proj/utun3 +abs_srcdir = /home/vnc1/proj/utun3 +abs_top_builddir = /home/vnc1/proj/utun3 +abs_top_srcdir = /home/vnc1/proj/utun3 ac_ct_AR = ar -ac_ct_CC = +ac_ct_CC = gcc am__include = include am__leading_dot = . am__quote = am__tar = $${TAR-tar} chof - "$$tardir" am__untar = $${TAR-tar} xf - bindir = ${exec_prefix}/bin -build = x86_64-w64-mingw32 -build_alias = x86_64-w64-mingw32 +build = x86_64-pc-linux-gnu +build_alias = build_cpu = x86_64 -build_os = mingw32 -build_vendor = w64 +build_os = linux-gnu +build_vendor = pc builddir = . datadir = ${datarootdir} datarootdir = ${prefix}/share docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} dvidir = ${docdir} exec_prefix = ${prefix} -host = x86_64-w64-mingw32 -host_alias = x86_64-w64-mingw32 +host = x86_64-pc-linux-gnu +host_alias = host_cpu = x86_64 -host_os = mingw32 -host_vendor = w64 +host_os = linux-gnu +host_vendor = pc htmldir = ${docdir} includedir = ${prefix}/include infodir = ${datarootdir}/info -install_sh = ${SHELL} /c/ARM/_uTun/utun2/build-aux/install-sh +install_sh = ${SHELL} /home/vnc1/proj/utun3/build-aux/install-sh libdir = ${exec_prefix}/lib libexecdir = ${exec_prefix}/libexec localedir = ${datarootdir}/locale diff --git a/src/etcp_connections.c b/src/etcp_connections.c index 6c8b9fcd8..3d7f0e072 100644 --- a/src/etcp_connections.c +++ b/src/etcp_connections.c @@ -485,10 +485,10 @@ int etcp_encrypt_send(struct ETCP_DGRAM* dgram) { dgram->timestamp=get_current_timestamp(); // DUMP: Show packet before encryption -// log_dump("ECTP_ENCRYPT_SEND", dgram->data, dgram->data_len); - DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Encrypt start"); + if (debug_should_output(DEBUG_LEVEL_DEBUG, DEBUG_CATEGORY_CRYPTO)) log_dump("ECTP_ENCRYPT_SEND", dgram->data, dgram->data_len); +// DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Encrypt start"); sc_encrypt(sc, (uint8_t*)&dgram->timestamp/*не править это, тут верно!*/, sizeof(uint16_t) + len, enc_buf, &enc_buf_len); - DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Encrypt end"); +// DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Encrypt end"); if (enc_buf_len == 0) { DEBUG_ERROR(DEBUG_CATEGORY_CRYPTO, "etcp_encrypt_send: encryption failed for node %llu", (unsigned long long)dgram->link->etcp->instance->node_id); dgram->link->send_errors++; @@ -499,7 +499,7 @@ int etcp_encrypt_send(struct ETCP_DGRAM* dgram) { memcpy(enc_buf+enc_buf_len, dgram->data+len, dgram->noencrypt_len); // DUMP: Show complete packet before sending -// log_dump("ENCRYPTED, READY TO SEND", enc_buf, enc_buf_len + dgram->noencrypt_len); + if (debug_should_output(DEBUG_LEVEL_DEBUG, DEBUG_CATEGORY_CRYPTO)) log_dump("ENCRYPTED, READY TO SEND", enc_buf, enc_buf_len + dgram->noencrypt_len); struct sockaddr_storage* addr=&dgram->link->remote_addr; socklen_t addr_len = (addr->ss_family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6); @@ -563,7 +563,7 @@ static void etcp_connections_read_callback_socket(socket_t sock, void* arg) { // printf("[ETCP] Received packet: %zd bytes from address\n", recv_len); // DUMP: Show received packet content -// log_dump("RECV in:", data, recv_len); // link unknown at this point + if (debug_should_output(DEBUG_LEVEL_DEBUG, DEBUG_CATEGORY_CRYPTO)) log_dump("RECV in:", data, recv_len); // link unknown at this point struct ETCP_DGRAM* pkt = memory_pool_alloc(e_sock->instance->pkt_pool); if (!pkt) return;