- chat_core_sync_my_addresses: DELETE + INSERT с подсчётом строк, CHECK verify
- chat_core_connect_from_invite: DELETE + INSERT с IP:port
- member_sync_put: DELETE + INSERT с IP:port, warn если addrs_data=NULL
- cs_handle_channel_info_resp: адрес инвайтера из ETCP link
- cs_handle_channel_join: адреса джойнера
- cs_handle_peer_upsert: адреса пира
- cs_handle_welcome: адреса из WELCOME
Все логи с префиксом [ADDR_SYNC] в DEBUG_CATEGORY_DEBUG
- mainwindow.cpp: swap setupMessaging() before setupNode() so g_receiver is created first
- gui_bridge_impl.cpp: add DEBUG_WARN when gui_bridge_post drops event due to NULL g_receiver
- utun_node.cpp: open topo_sqlite_db with FULLMUTEX + all PRAGMAs (WAL, FK, NORMAL sync, checkpoint)
- db_sync.c: reuse inst->topo_sqlite_db if available (shared_db flag)
- chat_core.c: reuse inst->topo_sqlite_db if available (shared_db flag)
- db_sync_destroy/chat_core_destroy: skip close on shared handle
- Only topo_groups_destroy closes the shared handle
- Fallback: each module opens own connection if topo_sqlite_db is NULL
- NodesPage: show full 64-bit Node ID (hex16) instead of truncated 4 hex chars
- NodesPage: show diagnostic when DB handle is NULL (was silent return)
- DatabaseSettingsPage: show 'Database not connected' when DB handle is NULL
- DatabaseSettingsPage: add refreshStatus() called on tab select
- SettingsDialog: refresh Database tab on category change
ready_cbks/etcp_conn_set_ready_cbk/add_ready/remove_ready → init_cbks/..._init_cbk
ca_ready_cb → ca_init_cb
cm_direct_ready_cb → cm_direct_init_cb
cm_reverse_ready_cb → cm_reverse_init_cb
ntp_node_on_conn_ready → ntp_node_on_conn_init
connect_ready_cb → connect_init_cb
init accurately describes when conn->initialized=1, before keepalives establish UP.
Also fire etcp_fire_conn_status INIT at this point instead of create time.
When INIT_SYNC arrives for an unknown hash, scan all msg_* tables in
sqlite_master, compute SHA256 of channel_id, match the hash, and
auto-register via db_sync_instance_add. Fixes invite flow where
channel was created but db_sync wasn't notified.
- chat_core.c: dump node_addresses total, per-node counts, nodes lookup before addr query
- topo_group.c: log db path, rc, and db pointer after sqlite3_open
- topo_group.c: open {db_path}/chats.db instead of {db_path} — was opening a directory
- chat_core.c: remove inst->topo_sqlite_db = g_cc.db — keep topo_sqlite_db as separate
uTun-only connection without FULLMUTEX, avoiding contention with GUI reads
- chat_core.c: add DEBUG_INFO before each synchronous cb(FAIL) — pinpoints exact failure reason
- chat_sync.c: add log in ac_fill when ca_state=NULL after chat_core_connect_auto call
- Add etcp_add_conn_status_cbk/remove/set — unified callback for all connections
- 4 statuses: NEW, UP, DOWN, DELETE — one subscription covers all connections
- Fire points in etcp.c: create→NEW, on_up→UP, on_down→DOWN, close→DELETE
- chat_sync.c: replace cs_on_new_conn+per-conn subs with cs_on_conn_status
- db_sync.c: same migration to instance-level callback
- cs_is_peer_online: use conn->links_up instead of link->link_status (was 0 during INIT handshake)
- db_sync: rename column author→node_id, open chats.db instead of sync file,
db_sync_instance_add takes table_name directly
- chat_core: remove CREATE TABLE msg_ch_*, remove on_db_sync_insert (74 lines),
remove fallback INSERT in submit_message, add minimal on_msg_inserted
for GUI notification only
- db_manager: update getMessages for new schema (parse JSON from data column),
fix ORDER BY to use author_signature instead of datahash,
update syncCursorNext to parse JSON
- si_register simplified: db_count from same table, no more msg vs sync gap
- chat_core_has_conn: search all connections (pending+ready) by peer_node_id
- chat_core_connect_from_invite: skip chat_core_connect_auto if already connected
- ca_timeout_cb: close timed-out connection to free socket link slot
+ cancel remaining timers + ca_cleanup on all-failed
- Add sync_start_tb to SI_PEER, set in db_sync_initiate_sync
- peer_check_cb: after 15s timeout reset sync_state=0 with WARN
- db_handle_error: accept si, reset sync_state=0, DEBUG_ERROR with details
- DB_SYNC_SYNC_TIMEOUT=15 added to db_sync.h
- Fix wrong categories: BGP/DEBUG -> ETCP for connection lifecycle events
- Fix level: WARN -> DEBUG for normal out-of-order pkts before init
- Fix level: INFO -> DEBUG for per-packet TX DATA spam
- Remove duplicate socket init logs (GENERAL duplicates of ETCP)
- Add missing INFO: INIT_RESPONSE received (client), INIT_RESPONSE sent (server)
- Unify all connection establishment messages under ETCP category
- Remove redundant DEBUG address prints in INIT send (info already in INFO msg)
- PING/PONG operations: BGP -> CONNECTION
- DIRECT IP detection: BGP -> NAT
- cs_handle_welcome(): add self to local peers_<ch_id> so
joiner sees own account in channel member list
- cs_on_conn_up(): post CHANNEL_PEERS_ONLINE after reconnect
so GUI shows connected status (was only posted on conn_down)
- etcp_loadbalancer: DEBUG_WARN -> DEBUG_DEBUG for no suitable
link: tmr:wait — normal shaper behavior, not a warning
- chat_core_sync_my_addresses(): remove private IP filter (192.168, 10.x, etc.)
so LAN addresses are stored for direct connections
- topo_node_sqlite_channel_peers_all(): include peers without addresses
in WELCOME message (was skipped entirely, causing empty peer list)
- chat_core_create_channel(): pass real local addresses to member_sync_put()
instead of NULL,0
- chat_core_init(): log number of channels loaded from DB on startup
sc_derive_node_id() hashed the private key, while invite links
(joindialog.cpp) hashed the public key — giving two different
node_ids for the same keypair.
Removed sc_derive_node_id(), kept only sc_derive_node_id_from_pubkey().
All callers updated to use pubkey-based derivation.
- topo_sqlite_db moved from TOPO_GROUPS to UTUN_INSTANCE (direct access)
- topo_groups_set_sqlite_db() removed
- chatgui: chat_sync_connect_node → chat_core_connect_auto (direct ETCP, no conn_mgr)
- chatgui: chat_core_connect_from_invite saves to SQLite → auto connect (no BGP)
- chatgui: removed _on_node_updated BGP callback from member_sync
- chatgui: removed conn_mgr_get_status from status dump
- chatgui: removed all conn_mgr.h and topo_group.h includes
- chatgui: CONN_MGR_ERR_* constants → CC_* in chat_core.h
- removed unused cc_parallel_* code, conn_state_str/conn_type_str helpers
- find_third_node: use nd->inst->connections instead of group->senders_list
- on_conn_up callback auto-calls trigger_checks (no BGP handshake needed)
- Remove group param from link_ready, request_check_all — nat_detection self-sufficient
- Remove trigger_checks + route_ping_cancel_for_conn from public API (internal only)
- topo_group.c: removed last nat_detection_trigger_checks call — completely decoupled
- Header: 4-line summary, no duplicate function list, 7 public functions
- Assign ETCP_ID_NAT_DETECTION = 0x02, etcp_bind in create, etcp_unbind in destroy
- nat_detection_receive_cbk: own packet dispatcher (PING_REQ/RESP, NAT_INFO/CHECK_REQ)
- 4 handle_* become static internal, send_nat_check_req stays static (dead code)
- Rename TOPO_* -> NATDET_*: all subcommands, structs, message types
- Remove all NAT/PING constants and structs from topo_group.h
- Remove dispatch lines and subcmd_name cases from topo_group_receive_cbk
- API: clear sections (lifecycle/internal service/control/test helpers)
- trigger_checks: marked with IMPORTANT note about call order (must be after add_to_senders)
Root cause: db_handle_init_resp marked sync_state=2 when my_dh==peer_dh
without checking that all my records fit in the confirmed prefix.
If mc > tp+1 (I have records beyond the common prefix), the tail was
never sent — lost records.
Fix:
- Remove special-case 'sc==0 && my_dh==peer_dh' (redundant, same bug)
- In general dh_match: if mc > tp+1, send remaining records [tp+1,mc-1]
using the same inline loop pattern as 'peer empty' branch
Test: 3 phases covering all dh_match paths:
- Phase 1: B empty+late instance → dh_match at tp=0 (sc=0) → tail-send 49
- Phase 2: A=80 B=50 → dh_match at tp=49 (sc>0, sparse) → tail-send 30
- Phase 3: fresh instances → peer empty → send all 30
- db_sync_on_conn_up: per-instance synced/skipped counters
- db_sync_peer_check_cb: summary INFO of check results
- db_sync_instance_add: peers_found + peers_synced counts
- db_handle_init_sync/initiate_sync: enhanced with tbl name
- db_handle_init_resp: tp + my_mc in sync complete/dh match
- db_handle_send_data: range + SYNC_DONE details; stop reason when mc>pk
- db_handle_sync_done: both counts + datahashes in mismatch; dh in confirm
- db_sync_recv_cb: INFO when instance NOT FOUND (timing race)
- cs_handle_channel_info_resp: sync readiness after channel ready
- cs_handle_welcome: note about db_sync peer_check timer
- on_db_sync_insert: counter (#1-3 then every 10) with ch/n/ts/dh/ct
Priority: iterate instance->connections for links with NAT_TYPE_DIRECT
(connected and reachable). Fallback: own socket addresses.
Removed broken getOnlinePeerAddresses() which returned other nodes' addresses.