chat: user-friendly INFO logs for invite/connect flow

- chat_sync.c: invite entry, JOINED/TIMEOUT messages
- conn_mgr_core.c: invite start (addrs+udp+tcp), NCD UP/DOWN/TIMEOUT,
  TCP connect/ready/close, membership check send/receive/confirm/deny,
  overall timeout
- node_conn_direct.c: NCD event names instead of numbers
This commit is contained in:
evgeny committed 2026-08-02 20:32:01 +03:00
1 parent c35135cb52
commit c2191aad3b
34 files changed
+597 -230

No files matched your search

+28 -7
View File
@@ -53,6 +53,19 @@ static void free_v6_sub_list(struct memory_pool* pool, struct TOPO_SUBNET6* head
while (head) { struct TOPO_SUBNET6* next = head->next; memory_pool_free(pool, head); head = next; }
}
/* извлекает hop_list из лучшего живого path в nq->paths (или любого, если живых нет).
память принадлежит TOPO_NODEPATH в paths, не освобождать */
uint64_t* topo_node_best_hop_list(struct TOPO_GROUP_NODE* nq, uint8_t* out_count, uint16_t* out_rtt) {
if (!nq || !nq->paths || !nq->paths->head) { *out_count = 0; if (out_rtt) *out_rtt = 0; return NULL; }
struct TOPO_NODEPATH* best = NULL; uint8_t min_hops = 255;
struct ll_entry* e = nq->paths->head;
while (e) { struct TOPO_NODEPATH* p = (struct TOPO_NODEPATH*)e; if (p->conn && p->conn->links_up && p->hop_count < min_hops) { best = p; min_hops = p->hop_count; } e = e->next; }
if (!best) best = (struct TOPO_NODEPATH*)nq->paths->head;
*out_count = best->hop_count;
if (out_rtt) *out_rtt = best->cumulative_rtt;
return (uint64_t*)((uint8_t*)best + sizeof(struct TOPO_NODEPATH));
}
void topo_node_free_raw(struct TOPO_GROUPS* groups, struct TOPO_NODE* ni) {
if (!ni) return;
if (groups) {
@@ -87,7 +100,6 @@ void topo_nodeq_free_group_fields(struct TOPO_GROUPS* groups, struct TOPO_GROUP_
u_free(nq->subnets);
nq->subnets = NULL;
}
u_free(nq->hop_list); nq->hop_list = NULL; nq->hop_count = 0;
nq->handle = NULL;
}
@@ -169,7 +181,8 @@ int topo_node_serialize(struct TOPO_NODE* ni, struct TOPO_GROUP_NODE* nq, uint8_
msg.local_v6_addrs = topo_list_count((struct _topo_head*)ni->v6_addrs);
msg.local_v4_subnets = nq->subnets ? topo_list_count((struct _topo_head*)nq->subnets->v4_subnets) : 0;
msg.local_v6_subnets = nq->subnets ? topo_list_count((struct _topo_head*)nq->subnets->v6_subnets) : 0;
msg.hop_count = nq->hop_count;
{ uint8_t hc; uint64_t* hl = topo_node_best_hop_list(nq, &hc, NULL);
msg.hop_count = hc; }
msg.cumulative_rtt = cumulative_rtt;
size_t total = TOPOMSG_NODE_HDR_SIZE + (size_t)topo_node_dyn_size(&msg);
@@ -208,10 +221,8 @@ int topo_node_serialize(struct TOPO_NODE* ni, struct TOPO_GROUP_NODE* nq, uint8_
}}
}
}
if (msg.hop_count && nq->hop_list) {
size_t sz = msg.hop_count * 8;
memcpy(dp, nq->hop_list, sz); dp += sz;
}
{ uint8_t hc; uint64_t* hl = topo_node_best_hop_list(nq, &hc, NULL);
if (hc && hl) { size_t sz = hc * 8; memcpy(dp, hl, sz); dp += sz; } }
return (int)(dp - out);
}
@@ -364,11 +375,22 @@ void topo_node_ping_update_rtt(struct TOPO_GROUPS* groups, uint64_t node_id, uin
(unsigned long long)node_id, (unsigned)rtt, (unsigned long long)now, (unsigned long long)g->group_id);
if (groups->instance && groups->instance->topo_sqlite_db)
topo_node_sqlite_update_rtt(groups->instance->topo_sqlite_db, node_id, rtt);
topo_fire_nodeinfo_cbk(groups->instance, g, nq);
}
ge = ge->next;
}
}
uint16_t node_best_rtt(struct TOPO_GROUP_NODE* nq) {
if (!nq) return 0xFFFF;
struct TOPO_CONNECTIVITY* c = &nq->connectivity;
uint16_t best = 0x3FFF; uint8_t type = 0;
if (c->interface_status == PROBE_RESULT_REACHABLE && c->interface_min_rtt < best) { best = c->interface_min_rtt; type = 0; }
if (c->nat_status == PROBE_RESULT_REACHABLE && c->nat_min_rtt < best) { best = c->nat_min_rtt; type = 1; }
if (c->real_status == PROBE_RESULT_REACHABLE && c->real_min_rtt < best) { best = c->real_min_rtt; type = 2; }
return ((uint16_t)type << 14) | best;
}
// ===== dump / format =====
static int is_node_connectivity_active(struct TOPO_CONNECTIVITY* c) {
@@ -658,7 +680,6 @@ int topo_group_update_my_nodeinfo(struct UTUN_INSTANCE* instance, struct TOPO_GR
topo_node_registry_store(instance->topo_groups, ni);
lq->node_id = ni->node_id;
lq->hop_count = 0;
lq->last_ver = ni->ver;
e_sock = instance->etcp_sockets;