|
|
|
|
@ -85,28 +85,6 @@ static void ncd_registry_remove(struct UTUN_INSTANCE* inst, struct ncd_entry* en
|
|
|
|
|
while (*pp) { if (*pp == entry) { *pp = entry->next; return; } pp = &(*pp)->next; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* TEMP DEBUG: сканирует inst->connections и выводит conn'ы с peer_node_id==node_id,
|
|
|
|
|
* которые instance_find_conn мог не вернуть (key=0 или дубликат ключа). */ |
|
|
|
|
static void ncd_debug_scan_conns(struct UTUN_INSTANCE* inst, uint64_t node_id, const char* tag) { |
|
|
|
|
struct ll_queue* q = inst->connections; |
|
|
|
|
if (!q) { DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "[ncd] %s node=0x%016llx: connections=NULL", tag, (unsigned long long)node_id); return; } |
|
|
|
|
int found = 0; |
|
|
|
|
struct ll_entry* e = q->head; |
|
|
|
|
while (e) { |
|
|
|
|
struct conn_queue_entry* ce = (struct conn_queue_entry*)e->data; |
|
|
|
|
if (ce && ce->conn && ce->conn->peer_node_id == node_id) { |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, |
|
|
|
|
"[ncd] %s node=0x%016llx: conn=%p [%s] state=%d qkey=0x%016llx links=%p up=%d init=%d", |
|
|
|
|
tag, (unsigned long long)node_id, (void*)ce->conn, ce->conn->log_name, |
|
|
|
|
ce->conn->state, (unsigned long long)ce->peer_node_id, (void*)ce->conn->links, |
|
|
|
|
ce->conn->links_up, ce->conn->initialized); |
|
|
|
|
found = 1; |
|
|
|
|
} |
|
|
|
|
e = e->next; |
|
|
|
|
} |
|
|
|
|
if (!found) DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "[ncd] %s node=0x%016llx: NO conn in queue", tag, (unsigned long long)node_id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* ═══════════ поиск узла ═══════════ */ |
|
|
|
|
/*
|
|
|
|
|
* Загружает информацию об узле (адреса, pubkey) для создания линков. |
|
|
|
|
@ -635,12 +613,6 @@ int node_conn_direct_open(struct UTUN_INSTANCE* inst, uint64_t node_id,
|
|
|
|
|
return NCD_REUSED; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (conn) { |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "[ncd] open node=0x%016llx: instance_find_conn=[%s] state=%d links=%p up=%d — NOT reused (state!=1), creating new", |
|
|
|
|
(unsigned long long)node_id, conn->log_name, conn->state, (void*)conn->links, conn->links_up); |
|
|
|
|
} |
|
|
|
|
ncd_debug_scan_conns(inst, node_id, "open-new"); |
|
|
|
|
|
|
|
|
|
/* 3. Новое подключение */ |
|
|
|
|
struct TOPO_NODE* ni = ncd_lookup_node(inst, node_id); |
|
|
|
|
if (!ni) { |
|
|
|
|
@ -795,8 +767,6 @@ int node_conn_direct_open_node(struct UTUN_INSTANCE* inst, uint64_t node_id,
|
|
|
|
|
return NCD_REUSED; |
|
|
|
|
}} |
|
|
|
|
|
|
|
|
|
ncd_debug_scan_conns(inst, node_id, "open_node-new"); |
|
|
|
|
|
|
|
|
|
/* 3. Новое подключение — используем переданный ni (временный, не владеем) */ |
|
|
|
|
{ char conn_name[MAX_CONN_NAME_LEN]; |
|
|
|
|
if (ni->node_name && ni->node_name[0]) strncpy(conn_name, ni->node_name, MAX_CONN_NAME_LEN - 1); |
|
|
|
|
|