Browse Source

fix: peers_* table creation + GUI_ERROR to log + cross-connect conn reuse

- chat_core.c: CREATE TABLE IF NOT EXISTS peers_* in ensure_channel_ready
- utun_node.cpp: GUI_ERROR redirected to debug log file via guiDebugFile()
- etcp_connections.c: reuse unindexed outbound conn (peer_node_id==0)
  on cross-connect INIT to avoid 'Can not insert link to socket'
topo_upd
Evgeny 3 months ago
parent
commit
c3354938e1
  1. 8
      src/etcp_connections.c
  2. 13
      tools/chatgui/transport/chat_core.c
  3. 2
      tools/chatgui/transport/utun_node.cpp

8
src/etcp_connections.c

@ -1677,6 +1677,14 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
struct ll_entry* e = queue_find_data_by_index(e_sock->instance->connections, (const uint8_t*)&peer_id);
if (e) { struct conn_queue_entry* ce = (struct conn_queue_entry*)e->data; conn = ce->conn; }
}
if (!conn) {
struct ETCP_LINK* ol = etcp_link_find_by_addr(e_sock, &addr);
if (ol && ol->etcp && ol->etcp->peer_node_id == 0) {
conn = ol->etcp;
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] reusing unindexed outbound conn for incoming INIT from peer=0x%016llx addr=%s",
conn->log_name, (unsigned long long)peer_id, sockaddr_storage_to_str(&addr).str);
}
}
int new_conn=0;
if (!conn || conn->peer_node_id!=peer_id) {// создаём новое подключение [new etcp]

13
tools/chatgui/transport/chat_core.c

@ -1018,6 +1018,19 @@ void chat_core_ensure_channel_ready(const char* ch_id) {
tbl_msg, tbl_msg);
db_exec(sql);
char tbl_peers[80]; peers_table_name(ch_id, tbl_peers, sizeof(tbl_peers));
snprintf(sql, sizeof(sql),
"CREATE TABLE IF NOT EXISTS \"%s\" ("
" node_id INTEGER PRIMARY KEY,"
" x25519_pubkey BLOB NOT NULL,"
" ed25519_pubkey BLOB,"
" join_sig BLOB,"
" join_ts INTEGER DEFAULT 0,"
" update_sig BLOB,"
" update_ts INTEGER DEFAULT 0"
")", tbl_peers);
db_exec(sql);
uint64_t ch_hash = 0;
{ const uint8_t* chd = (const uint8_t*)ch_id; size_t chl = strlen(ch_id); uint8_t sh[32]; SHA256(chd, chl, sh); memcpy(&ch_hash, sh, 8); }
struct DB_SYNC_INSTANCE* si = db_sync_instance_add(g_cc.inst, "chats", ch_hash);

2
tools/chatgui/transport/utun_node.cpp

@ -5,6 +5,7 @@
#include "../../lib/socket_compat.h"
#include "../db/db_manager.h"
#include "../src/debug_ui.h"
// === C headers ===
extern "C" {
@ -205,6 +206,7 @@ void UtunNode::runLoop() {
debug_enable_file_output(m_debugFile.toUtf8().constData(), 0);
debug_enable_console(1);
g_debug_config.thread_marker = 2;
guiDebugFile(m_debugFile.toUtf8().constData());
}
utun_instance_set_tun_init_enabled(0);

Loading…
Cancel
Save