From 6bf267924dbfc95bcf48d81afe7ce10c528e552a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 13 Jul 2026 15:14:48 +0300 Subject: [PATCH] add DEBUG_CATEGORY_CONNECTIVITY for handshake/protocol lifecycle logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New category (id=25) replaces DEBUG_CATEGORY_DEBUG in chat_sync and chat_core. This allows enabling only protocol-level logs (SEND/RECV, timeouts, handshake) without the noise from DEBUG category. Changes: - debug_config.h: add CONNECTIVITY=25, COUNT→26 - debug_config.c: add 'connectivity' to g_debug_categories - chat_sync.c: DEBUG→CONNECTIVITY in all protocol logs - chat_core.c: DEBUG→CONNECTIVITY in connection/create logs - utun_node.cpp: remove hardcoded DEBUG=TRACE (now config-driven) - chatgui.cfg: connectivity=info in debug_categories --- lib/debug_config.c | 1 + lib/debug_config.h | 3 +- tools/chatgui/transport/chat_core.c | 62 +++++++++++++-------------- tools/chatgui/transport/chat_sync.c | 34 +++++++-------- tools/chatgui/transport/utun_node.cpp | 1 - 5 files changed, 51 insertions(+), 50 deletions(-) diff --git a/lib/debug_config.c b/lib/debug_config.c index f3134de0..a9a29d91 100644 --- a/lib/debug_config.c +++ b/lib/debug_config.c @@ -129,6 +129,7 @@ static const struct { {"etcp_route", DEBUG_CATEGORY_ETCPROUTE}, {"bbr", DEBUG_CATEGORY_BBR}, {"etcp_dump", DEBUG_CATEGORY_ETCP_DUMP}, + {"connectivity", DEBUG_CATEGORY_CONNECTIVITY}, {"all", DEBUG_CATEGORY_ALL}, {NULL, DEBUG_CATEGORY_NONE} }; diff --git a/lib/debug_config.h b/lib/debug_config.h index d2114f98..0cd34b8c 100644 --- a/lib/debug_config.h +++ b/lib/debug_config.h @@ -63,7 +63,8 @@ typedef int debug_category_t; #define DEBUG_CATEGORY_ETCPROUTE 22 // ETCP routing #define DEBUG_CATEGORY_BBR 23 // BBR congestion control #define DEBUG_CATEGORY_ETCP_DUMP 24 // ETCP packet dump -#define DEBUG_CATEGORY_COUNT 25 // Total number of categories +#define DEBUG_CATEGORY_CONNECTIVITY 25 // Connection/handshake lifecycle +#define DEBUG_CATEGORY_COUNT 26 // Total number of categories #define DEBUG_CATEGORY_ALL (-1) // special value for all categories /* Debug configuration structure */ diff --git a/tools/chatgui/transport/chat_core.c b/tools/chatgui/transport/chat_core.c index 5edd7ae4..6b09089f 100644 --- a/tools/chatgui/transport/chat_core.c +++ b/tools/chatgui/transport/chat_core.c @@ -107,7 +107,7 @@ static int db_exec(const char* sql) { char* err = NULL; int rc = sqlite3_exec(g_cc.db, sql, NULL, NULL, &err); if (rc != SQLITE_OK) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: sql error: %s", CC_ID, err); + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: sql error: %s", CC_ID, err); sqlite3_free(err); } return rc; @@ -121,7 +121,7 @@ int chat_core_init(struct UTUN_INSTANCE* inst, const char* db_path) { int rc = sqlite3_open(db_path, &g_cc.db); if (rc != SQLITE_OK) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: cannot open DB %s: %s", + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: cannot open DB %s: %s", CC_ID, db_path, sqlite3_errmsg(g_cc.db)); sqlite3_close(g_cc.db); g_cc.db = NULL; return -1; } @@ -162,7 +162,7 @@ int chat_core_init(struct UTUN_INSTANCE* inst, const char* db_path) { ); g_cc.initialized = 1; - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: initialized, db=%s node_id=0x%016llx", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: initialized, db=%s node_id=0x%016llx", CC_ID, db_path, (unsigned long long)g_cc.my_node_id); return 0; } @@ -177,7 +177,7 @@ void chat_core_destroy(struct UTUN_INSTANCE* inst) { if (g_cc.db) { sqlite3_close(g_cc.db); g_cc.db = NULL; } g_cc.inst = NULL; - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: destroyed", CC_ID); + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: destroyed", CC_ID); } void chat_core_set_my_node_id(uint64_t node_id) { @@ -188,7 +188,7 @@ void chat_core_set_my_node_id(uint64_t node_id) { void chat_core_submit_message(struct chat_msg_submit* req) { if (!g_cc.initialized) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: submit_message called before init", CC_ID); + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: submit_message called before init", CC_ID); return; } if (!req) return; @@ -213,7 +213,7 @@ void chat_core_submit_message(struct chat_msg_submit* req) { sqlite3_stmt* stmt = NULL; if (sqlite3_prepare_v2(g_cc.db, sql, -1, &stmt, NULL) != SQLITE_OK) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: prepare insert failed: %s", + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: prepare insert failed: %s", CC_ID, sqlite3_errmsg(g_cc.db)); return; } @@ -231,17 +231,17 @@ void chat_core_submit_message(struct chat_msg_submit* req) { sqlite3_finalize(stmt); if (rc == SQLITE_DONE) { - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: msg inserted ch=%s ts=%llu dh=0x%016llx", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: msg inserted ch=%s ts=%llu dh=0x%016llx", CC_ID, ch_id, (unsigned long long)ts, (unsigned long long)dh); /* push пирам */ chat_sync_push(g_cc.inst, ch_id, g_cc.my_node_id, req->content_type, data, data_len, ts, dh); } else if (rc == SQLITE_CONSTRAINT) { - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: msg duplicate ch=%s ts=%llu", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: msg duplicate ch=%s ts=%llu", CC_ID, ch_id, (unsigned long long)ts); } else { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: insert msg failed: %s", + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: insert msg failed: %s", CC_ID, sqlite3_errmsg(g_cc.db)); } } @@ -253,7 +253,7 @@ void chat_core_submit_trampoline(void* arg) { void chat_core_push_message(struct chat_msg_submit* req) { if (!g_cc.initialized) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: push_message called before init", CC_ID); + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: push_message called before init", CC_ID); return; } if (!req) return; @@ -261,7 +261,7 @@ void chat_core_push_message(struct chat_msg_submit* req) { uint64_t dh; compute_datahash(req->data, req->data_len, &dh); - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: pushing msg ch=%s ts=%llu dh=0x%016llx", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: pushing msg ch=%s ts=%llu dh=0x%016llx", CC_ID, req->channel_id, (unsigned long long)req->timestamp, (unsigned long long)dh); chat_sync_push(g_cc.inst, req->channel_id, g_cc.my_node_id, @@ -340,7 +340,7 @@ int chat_core_insert_record(const char* ch_id, const uint8_t* rec, size_t len) { uint8_t expected[32]; compute_chain_hash(prev, ts, dh, expected); if (memcmp(expected, peer_ch, 32) != 0) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: chain_hash mismatch ch=%s ts=%lld dh=0x%016llx", + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: chain_hash mismatch ch=%s ts=%lld dh=0x%016llx", CC_ID, ch_id, (long long)ts, (unsigned long long)dh); return -1; } @@ -623,7 +623,7 @@ static void cc_parallel_ready_cb(struct ETCP_CONN* conn, void* arg) { memcpy(data + 12, &st->channel_id, 8); gui_bridge_post(GUI_EVT_CONNECT_RESULT, data, 20); - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: parallel connect SUCCESS idx=%d peer=0x%016llx", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: parallel connect SUCCESS idx=%d peer=0x%016llx", CC_ID, pctx->addr_index, (unsigned long long)st->node_id); for (int i = 0; i < st->addr_count; i++) { @@ -643,7 +643,7 @@ static void cc_parallel_timeout_cb(void* arg) { st->timers[pctx->addr_index] = NULL; st->pending_count--; - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: parallel connect TIMEOUT idx=%d pending=%d/%d peer=0x%016llx", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: parallel connect TIMEOUT idx=%d pending=%d/%d peer=0x%016llx", CC_ID, pctx->addr_index, st->pending_count, st->addr_count, (unsigned long long)st->node_id); if (st->pending_count <= 0 && !st->completed) { @@ -663,7 +663,7 @@ void chat_core_connect_from_invite(struct chat_invite* inv) { if (!g_cc.initialized || !g_cc.inst || !inv) return; struct TOPO_GROUP* group = topo_groups_get_default(g_cc.inst->topo_groups); if (!group || !g_cc.inst->conn_mgr) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: bgp/conn_mgr not available", CC_ID); + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: bgp/conn_mgr not available", CC_ID); uint8_t err[12]; int r = -7; memcpy(err, &inv->node_id, 8); memcpy(err + 8, &r, 4); gui_bridge_post(GUI_EVT_CONNECT_RESULT, err, 12); @@ -673,7 +673,7 @@ void chat_core_connect_from_invite(struct chat_invite* inv) { uint64_t node_id = inv->node_id; if (topo_node_find_by_id(group, node_id)) { - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: node 0x%016llx already in BGP, connecting", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: node 0x%016llx already in BGP, connecting", CC_ID, (unsigned long long)node_id); conn_mgr_connect_node(g_cc.inst->conn_mgr, node_id, 30000, connect_result_cb, &inv->channel_id); @@ -682,7 +682,7 @@ void chat_core_connect_from_invite(struct chat_invite* inv) { struct ll_entry* qe = queue_entry_new(sizeof(struct TOPO_NODEQ)); if (!qe) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: failed to alloc TOPO_NODEQ", CC_ID); + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: failed to alloc TOPO_NODEQ", CC_ID); uint8_t err[12]; int r = -7; memcpy(err, &node_id, 8); memcpy(err + 8, &r, 4); gui_bridge_post(GUI_EVT_CONNECT_RESULT, err, 12); @@ -730,14 +730,14 @@ void chat_core_connect_from_invite(struct chat_invite* inv) { queue_data_put_with_index(group->nodes, &nq->ll); - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: created NODEINFO for 0x%016llx, %d addrs, parallel connect", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: created NODEINFO for 0x%016llx, %d addrs, parallel connect", CC_ID, (unsigned long long)node_id, inv->addr_count); /* count IPv4 addresses and collect them for parallel connect */ int v4_count = 0; for (struct TOPO_ADDR4* a = addrs_head; a; a = a->next) v4_count++; if (v4_count == 0) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: no IPv4 addresses in invite", CC_ID); + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: no IPv4 addresses in invite", CC_ID); uint8_t err[20]; memcpy(err, &node_id, 8); int r = CONN_MGR_ERR_NO_ADDRESSES; memcpy(err + 8, &r, 4); memset(err + 12, 0, 8); gui_bridge_post(GUI_EVT_CONNECT_RESULT, err, 20); @@ -747,7 +747,7 @@ void chat_core_connect_from_invite(struct chat_invite* inv) { struct ETCP_SOCKET* best_socket = g_cc.inst->etcp_sockets; while (best_socket && best_socket->local_addr.ss_family != AF_INET) best_socket = best_socket->next; if (!best_socket) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: no AF_INET socket", CC_ID); + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: no AF_INET socket", CC_ID); uint8_t err[20]; memcpy(err, &node_id, 8); int r = CONN_MGR_ERR_INTERNAL; memcpy(err + 8, &r, 4); memset(err + 12, 0, 8); gui_bridge_post(GUI_EVT_CONNECT_RESULT, err, 20); @@ -781,7 +781,7 @@ void chat_core_connect_from_invite(struct chat_invite* inv) { struct ETCP_CONN* conn = etcp_connection_create(g_cc.inst, NULL); if (!conn) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: etcp_connection_create failed idx=%d", CC_ID, idx); + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: etcp_connection_create failed idx=%d", CC_ID, idx); pst->conns[idx] = NULL; pst->timers[idx] = NULL; pst->pending_count--; continue; } sc_init_ctx(&conn->crypto_ctx, &g_cc.inst->my_keys); @@ -794,20 +794,20 @@ void chat_core_connect_from_invite(struct chat_invite* inv) { etcp_conn_set_ready_cbk(conn, cc_parallel_ready_cb, pctx); if (!etcp_link_new(conn, best_socket, &sa, 0)) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: etcp_link_new failed idx=%d", CC_ID, idx); + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: etcp_link_new failed idx=%d", CC_ID, idx); u_free(pctx); etcp_connection_close(conn); pst->conns[idx] = NULL; pst->timers[idx] = NULL; pst->pending_count--; continue; } pst->conns[idx] = conn; pst->timers[idx] = uasync_set_timeout(g_cc.inst->ua, CC_PARALLEL_CONNECT_TIMEOUT_MS * 10, pctx, cc_parallel_timeout_cb, "cc_parallel"); - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: parallel connect attempt %d/%d to %d.%d.%d.%d:%d", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: parallel connect attempt %d/%d to %d.%d.%d.%d:%d", CC_ID, idx + 1, v4_count, sin.sin_addr.s_addr & 0xFF, (sin.sin_addr.s_addr >> 8) & 0xFF, (sin.sin_addr.s_addr >> 16) & 0xFF, (sin.sin_addr.s_addr >> 24) & 0xFF, a->port); } if (pst->pending_count <= 0 && !pst->completed) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: all %d parallel connects failed to start", CC_ID, v4_count); + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: all %d parallel connects failed to start", CC_ID, v4_count); uint8_t err[20]; memcpy(err, &node_id, 8); int r = CONN_MGR_ERR_UNREACHABLE; memcpy(err + 8, &r, 4); memcpy(err + 12, &inv->channel_id, 8); gui_bridge_post(GUI_EVT_CONNECT_RESULT, err, 20); @@ -819,13 +819,13 @@ void chat_core_connect_from_invite(struct chat_invite* inv) { void chat_core_create_channel(struct chat_channel_create* req) { if (!g_cc.initialized) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: create_channel NOT INITIALIZED ch=%s", + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: create_channel NOT INITIALIZED ch=%s", CC_ID, req ? req->channel_id : "(null)"); return; } - if (!req) { DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: create_channel req=NULL", CC_ID); return; } + if (!req) { DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: create_channel req=NULL", CC_ID); return; } - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: create_channel BEGIN ch=%s name=%s", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: create_channel BEGIN ch=%s name=%s", CC_ID, req->channel_id, req->name); char tbl_msg[80]; msg_table_name(req->channel_id, tbl_msg, sizeof(tbl_msg)); @@ -860,10 +860,10 @@ void chat_core_create_channel(struct chat_channel_create* req) { req->signature); if (rc != 0) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: channel_put FAILED ch=%s rc=%d", + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: channel_put FAILED ch=%s rc=%d", CC_ID, req->channel_id, rc); } else { - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: channel_put OK ch=%s name=%s owner=0x%016llx", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: channel_put OK ch=%s name=%s owner=0x%016llx", CC_ID, req->channel_id, req->name, (unsigned long long)req->owner_node_id); /* уведомляем GUI */ @@ -872,13 +872,13 @@ void chat_core_create_channel(struct chat_channel_create* req) { data[0] = ch_id_len; memcpy(data + 1, req->channel_id, ch_id_len); gui_bridge_post(GUI_EVT_CHANNEL_UPDATED, data, 1 + ch_id_len); - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: gui_bridge_post sent GUI_EVT_CHANNEL_UPDATED ch=%s", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: gui_bridge_post sent GUI_EVT_CHANNEL_UPDATED ch=%s", CC_ID, req->channel_id); } } void chat_core_create_channel_trampoline(void* arg) { - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "chat_core: TRAMPOLINE invoked arg=%p", arg); + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "chat_core: TRAMPOLINE invoked arg=%p", arg); struct chat_channel_create* req = (struct chat_channel_create*)arg; chat_core_create_channel(req); u_free(req); diff --git a/tools/chatgui/transport/chat_sync.c b/tools/chatgui/transport/chat_sync.c index 6c498740..7c77de28 100644 --- a/tools/chatgui/transport/chat_sync.c +++ b/tools/chatgui/transport/chat_sync.c @@ -88,7 +88,7 @@ static int cs_send(struct chat_sync* cs, const char* ch_id, uint64_t dst, struct ll_entry* entry = queue_entry_new(0); if (!entry) { u_free(buf); return -1; } entry->dgram = buf; entry->len = total; - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: SEND %s to=%016llx ch=%s len=%zu", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: SEND %s to=%016llx ch=%s len=%zu", CS_ID, cs_msg_name(payload[0]), (unsigned long long)dst, ch_id, len); return etcp_route_send(cs->inst, dst, entry, 0); } @@ -312,7 +312,7 @@ static void chat_sync_recv_cb(struct ETCP_CONN* conn, struct ll_entry* entry) { const uint8_t* pl = d + 3 + ch_len; size_t plen = dlen - 3 - ch_len; - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: RECV %s from=%016llx ch=%s len=%zu", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: RECV %s from=%016llx ch=%s len=%zu", CS_ID, cs_msg_name(type), (unsigned long long)peer, ch_id, plen); switch (type) { @@ -328,7 +328,7 @@ static void chat_sync_recv_cb(struct ETCP_CONN* conn, struct ll_entry* entry) { case CS_MSG_WELCOME: cs_handle_welcome(g_cs, peer, ch_id, pl, plen); break; case CS_MSG_PEER_UPSERT: cs_handle_peer_upsert(g_cs, peer, ch_id, pl, plen); break; case CS_MSG_PEER_REMOVE: cs_handle_peer_remove(g_cs, peer, ch_id, pl, plen); break; - default: DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "%s: UNKNOWN msg type=%02x from=%016llx", CS_ID, type, (unsigned long long)peer); break; + default: DEBUG_WARN(DEBUG_CATEGORY_CONNECTIVITY, "%s: UNKNOWN msg type=%02x from=%016llx", CS_ID, type, (unsigned long long)peer); break; } u_free(entry->dgram); queue_entry_free(entry); } @@ -339,7 +339,7 @@ static void cs_info_req_timeout_cb(void* arg) { struct chat_sync* cs = (struct chat_sync*)arg; if (!cs || !cs->initialized) return; cs->info_req_timer = NULL; - DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "%s: CHANNEL_INFO_REQ timeout peer=%016llx ch=%llu", + DEBUG_WARN(DEBUG_CATEGORY_CONNECTIVITY, "%s: CHANNEL_INFO_REQ timeout peer=%016llx ch=%llu", CS_ID, (unsigned long long)cs->pending_invite_node_id, (unsigned long long)cs->pending_invite_ch_id); uint8_t err[12]; memcpy(err, &cs->pending_invite_node_id, 8); @@ -354,7 +354,7 @@ static void cs_join_timeout_cb(void* arg) { if (!cs || !cs->initialized) return; cs->join_timer = NULL; uint64_t peer = cs->pending_invite_node_id; - DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "%s: CHANNEL_JOIN timeout peer=%016llx ch=%llu", + DEBUG_WARN(DEBUG_CATEGORY_CONNECTIVITY, "%s: CHANNEL_JOIN timeout peer=%016llx ch=%llu", CS_ID, (unsigned long long)peer, (unsigned long long)cs->pending_invite_ch_id); uint8_t err[20]; memcpy(err, &peer, 8); int r = CONN_MGR_ERR_TIMEOUT; memcpy(err + 8, &r, 4); @@ -403,7 +403,7 @@ static void cs_on_conn_down(struct ETCP_CONN* conn, void* arg) { uint64_t peer = conn->peer_node_id; cs_cancel_proto_timers(g_cs); if (g_cs->pending_invite_node_id == peer) { - DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "%s: conn down while waiting invite resp peer=%016llx", CS_ID, (unsigned long long)peer); + DEBUG_WARN(DEBUG_CATEGORY_CONNECTIVITY, "%s: conn down while waiting invite resp peer=%016llx", CS_ID, (unsigned long long)peer); g_cs->pending_invite_node_id = 0; g_cs->pending_invite_ch_id = 0; } @@ -522,7 +522,7 @@ int chat_sync_init(struct UTUN_INSTANCE* inst, cs->info_req_timer = NULL; cs->join_timer = NULL; - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: initialized", CS_ID); + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: initialized", CS_ID); return 0; } @@ -631,7 +631,7 @@ void chat_sync_connect_from_invite(uint64_t channel_id, uint64_t node_id, static int cs_ed25519_sign(const uint8_t* privkey, const uint8_t* msg, size_t msg_len, uint8_t* sig_out) { EVP_PKEY* pkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_ED25519, NULL, privkey, SC_PRIVKEY_SIZE); - if (!pkey) { DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: EVP_PKEY_new failed", CS_ID); return -1; } + if (!pkey) { DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: EVP_PKEY_new failed", CS_ID); return -1; } EVP_MD_CTX* mdctx = EVP_MD_CTX_new(); if (!mdctx) { EVP_PKEY_free(pkey); return -1; } int ok = (EVP_DigestSignInit(mdctx, NULL, NULL, NULL, pkey) == 1) @@ -644,7 +644,7 @@ static int cs_ed25519_sign(const uint8_t* privkey, const uint8_t* msg, size_t ms static int cs_ed25519_verify(const uint8_t* pubkey, const uint8_t* msg, size_t msg_len, const uint8_t* sig) { EVP_PKEY* pkey = EVP_PKEY_new_raw_public_key(EVP_PKEY_ED25519, NULL, pubkey, SC_PUBKEY_SIZE); - if (!pkey) { DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: EVP_PKEY_new pub failed", CS_ID); return -1; } + if (!pkey) { DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: EVP_PKEY_new pub failed", CS_ID); return -1; } EVP_MD_CTX* mdctx = EVP_MD_CTX_new(); if (!mdctx) { EVP_PKEY_free(pkey); return -1; } int rc = EVP_DigestVerifyInit(mdctx, NULL, NULL, NULL, pkey) @@ -677,7 +677,7 @@ static void cs_handle_channel_info_req(struct chat_sync* cs, uint64_t peer, char name[128]; int is_dm; uint64_t owner; uint8_t x25519[32], ed_pub[32], ch_sig[64]; if (topo_node_sqlite_channel_get(cs->inst->topo_groups->topo_sqlite_db, ch_id, name, (int)sizeof(name), &is_dm, &owner, x25519, ed_pub, ch_sig) != 0) { - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: CHANNEL_INFO_REQ unknown ch=%s", CS_ID, ch_id); + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: CHANNEL_INFO_REQ unknown ch=%s", CS_ID, ch_id); return; } uint64_t myid = cs->inst->node_id; @@ -725,7 +725,7 @@ static void cs_handle_channel_info_resp(struct chat_sync* cs, uint64_t peer, memcpy(vmsg + vlen, x25519, 32); vlen += 32; memcpy(vmsg + vlen, ed_pub, 32); vlen += 32; if (cs_ed25519_verify(ed_pub, vmsg, vlen, ch_sig) != 0) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: CHANNEL_INFO_RESP invalid ch_sig ch=%s", CS_ID, ch_id); + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: CHANNEL_INFO_RESP invalid ch_sig ch=%s", CS_ID, ch_id); return; } @@ -813,7 +813,7 @@ static void cs_handle_channel_join(struct chat_sync* cs, uint64_t peer, memcpy(vmsg + vlen, &node_id, 8); vlen += 8; memcpy(vmsg + vlen, x25519, 32); vlen += 32; if (cs_ed25519_verify(ed_pub, vmsg, vlen, join_sig) != 0) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: JOIN invalid sig node=0x%016llx ch=%s", CS_ID, + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: JOIN invalid sig node=0x%016llx ch=%s", CS_ID, (unsigned long long)node_id, ch_id); return; } @@ -880,7 +880,7 @@ static void cs_handle_channel_join(struct chat_sync* cs, uint64_t peer, ch = cs_find(cs, ch_id); } - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: JOIN accepted node=0x%016llx ch=%s addrs=%d", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: JOIN accepted node=0x%016llx ch=%s addrs=%d", CS_ID, (unsigned long long)node_id, ch_id, addr_cnt); } @@ -933,7 +933,7 @@ static void cs_handle_welcome(struct chat_sync* cs, uint64_t peer, evt[0] = ch_id_len; memcpy(evt + 1, ch_id, ch_id_len); gui_bridge_post(GUI_EVT_CHANNEL_UPDATED, evt, 1 + ch_id_len); - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: WELCOME processed ch=%s peers=%d", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: WELCOME processed ch=%s peers=%d", CS_ID, ch_id, pc); } @@ -955,7 +955,7 @@ static void cs_handle_peer_upsert(struct chat_sync* cs, uint64_t peer, memcpy(vmsg + vlen, &node_id, 8); vlen += 8; memcpy(vmsg + vlen, x25519, 32); vlen += 32; if (cs_ed25519_verify(ed_pub, vmsg, vlen, join_sig) != 0) { - DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: PEER_UPSERT invalid sig node=0x%016llx", CS_ID, + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: PEER_UPSERT invalid sig node=0x%016llx", CS_ID, (unsigned long long)node_id); return; } @@ -989,7 +989,7 @@ static void cs_handle_peer_upsert(struct chat_sync* cs, uint64_t peer, /* propagate to others (except sender and the subject node) */ cs_propagate(cs, ch_id, peer, pl, len); - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: PEER_UPSERT node=0x%016llx ch=%s", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: PEER_UPSERT node=0x%016llx ch=%s", CS_ID, (unsigned long long)node_id, ch_id); } @@ -1006,6 +1006,6 @@ static void cs_handle_peer_remove(struct chat_sync* cs, uint64_t peer, cs_propagate(cs, ch_id, peer, pl, len); - DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: PEER_REMOVE node=0x%016llx ch=%s", + DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: PEER_REMOVE node=0x%016llx ch=%s", CS_ID, (unsigned long long)node_id, ch_id); } diff --git a/tools/chatgui/transport/utun_node.cpp b/tools/chatgui/transport/utun_node.cpp index 8443c8bd..166aafc5 100644 --- a/tools/chatgui/transport/utun_node.cpp +++ b/tools/chatgui/transport/utun_node.cpp @@ -174,7 +174,6 @@ void UtunNode::runLoop() { /* chatgui defaults: suppress spam, verbose for our categories */ g_debug_config.category_levels[DEBUG_CATEGORY_MEMORY] = DEBUG_LEVEL_DISABLED; g_debug_config.category_levels[DEBUG_CATEGORY_TIMING] = DEBUG_LEVEL_DISABLED; - g_debug_config.category_levels[DEBUG_CATEGORY_DEBUG] = DEBUG_LEVEL_TRACE; g_debug_config.category_levels[DEBUG_CATEGORY_BGP] = DEBUG_LEVEL_INFO; /* per-category overrides from config: cat=level,cat=level,... */