topo_group_connect: авто-подключение CHAT-групп + conn_mgr_connect_from_invite + замена chat_conn_mgr в chatgui

Добавлено:
- conn_mgr_connect_from_invite() — подключение к новому узлу по invite-данным
  (INIT → INVITE_INFO_REQ/RESP → проверка членства в группе → сохранение в БД)
- topo_group_connect.c — авто-подключение при старте CHAT-группы:
  Phase 1: одновременный connect всех connected=1 пиров, таймаут, отмена незавершённых
  Phase 2: последовательный перебор публичных адресов до первого успеха
- Счётчик active_conn_count с проверкой nodeinfo-путей (UP/DOWN)
- restart() при phase=DONE и count==0

БД:
- connected INTEGER NOT NULL DEFAULT 0 в peers_<ch> + ALTER TABLE для существующих
- topo_node_sqlite_set_connected / get_connected_peers / get_public_peers

Chatgui:
- Включён topo_group (убран utun_instance_set_topo_group_enabled(0))
- Создание TOPO_GROUP_TYPE_CHAT при channel_ready и при старте
- Invite connect через conn_mgr_connect_from_invite
- Удалён chat_conn_mgr (из сборки) + весь старый auto-connect код
This commit is contained in:
Evgeny committed 2026-07-22 22:48:12 +03:00
1 parent 4215349349
commit 6edd40d141
16 files changed
+834 -271

No files matched your search

+22 -3
View File
@@ -28,6 +28,7 @@ extern "C" {
#include "gui_bridge.h"
#include "topo_node_sqlite.h"
#include "topo_node.h"
#include "topo_group.h"
}
#define ETCP_RT_ID_CHAT 0x11
@@ -252,7 +253,6 @@ void UtunNode::runLoop() {
}
utun_instance_set_tun_init_enabled(0);
utun_instance_set_topo_group_enabled(0);
struct UASYNC* ua = uasync_create();
if (!ua) {
@@ -315,8 +315,27 @@ void UtunNode::runLoop() {
/* Initialize chat_core (DB) and chat_sync (channel/message P2P sync) */
chat_core_init(m_instance, QString(m_dbPath + "/chats.db").toUtf8().constData());
chat_sync_init(m_instance, nullptr);
chat_sync_auto_connect_start(m_instance);
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "chat_core + chat_sync + auto_connect initialized");
/* create TOPO_GROUP_TYPE_CHAT for all existing channels */
if (m_instance->topo_groups) {
uint8_t buf[4096]; size_t ch_len = 0;
chat_core_list_channels(buf, sizeof(buf), &ch_len);
if (ch_len >= 2) {
uint16_t cnt; memcpy(&cnt, buf, 2);
const uint8_t* p = buf + 2; size_t rem = ch_len - 2;
for (uint16_t i = 0; i < cnt && rem >= 1; i++) {
uint8_t id_len = *p++; rem--;
if (rem < id_len) break;
char ch_id[64]; memcpy(ch_id, p, id_len < 63 ? id_len : 63); ch_id[id_len < 63 ? id_len : 63] = 0;
p += id_len; rem -= id_len;
uint64_t gid = strtoull(ch_id, NULL, 10);
if (gid != 0 && !topo_groups_find(m_instance->topo_groups, gid))
topo_groups_create_group(m_instance->topo_groups, gid, TOPO_GROUP_TYPE_CHAT, ch_id);
}
}
}
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "chat_core + chat_sync initialized");
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "utun_node: entering poll loop");
while (!m_stop) {