- etcp_connections.h: add WIRE_OVERHEAD, IP_UDP_OVERHEAD_V4/V6, SC_ENCRYPT_OVERHEAD
(properly accounts for v6 IP(40)+UDP(8)+SC(3)+CCM tag(16) = 67 vs old UDP_HDR_SIZE=28)
- etcp_connections.c etcp_encrypt_send: use WIRE_OVERHEAD instead of UDP_HDR_SIZE
- etcp_connections.c send_init_response: clamp padding to max_data = mtu - WIRE_OVERHEAD
- chat_core_priv.h: add addr_type_from_ip() classifier
- chat_profile.c, chat_sync.c, member_sync.c: use classified addr_type instead of hardcoded 0
- chat_sync.c: skip zero nat_addr in JOIN, fall back to interface_addr
- topo_node_sqlite.c, member_sync.c: remove addr_type=0 filter from SELECT/DELETE
- chat_profile.c, member_sync.c: DELETE all addresses (not just addr_type=0)
- auto_socket.c/h: создание/удаление UDP сокетов автоматически при изменении интерфейсов через netlink/route socket
При auto_sockets=yes пропускает ручные [server] сокеты
Тип сокета: PUBLIC если публичный IP, иначе NAT
Для новых сокетов добавляются линки ко всем активным NCD-соединениям
При удалении интерфейса линки убираются, сокет закрывается
Platform-agnostic API для использования из Android/chatgui
- node_conn_direct.h/c: ncd_add_socket_links / ncd_remove_socket_links — управление линками на конкретном сокете
- socket_monitor.h/c: экспорт socket_monitor_update_if_addr для auto_socket
- config_parser.h/c: опция auto_sockets в [global]
- init_sockets(): пропуск ручных сокетов при auto_sockets=yes
- utun_instance: интеграция auto_socket_init/destroy
- media_delivery: fix stack-buffer-overflow ack[3] → ack[9]
- topo_node: fix heap-use-after-free в topo_group_update_my_nodeinfo — сохранение node_id/ver перед registry_store, использование return value
- etcp.c:466: %d→%s for log_name (was printing garbage like -2012603448)
- etcp_connections.c:2235: Server type %d→%s with server_type_str()
- etcp_connections.c:845,1578,1587: type=%d/nat_type=%d→%s with helpers
1. etcp_on_down: add down_link param — log the specific lost link + remaining
Connection DOWN — link 192.168.40.247:2122 lost, remaining: [::1]:6669, [::2]:9970
Connection DOWN — closing, links: ... (for reinit/close)
2. etcp_on_link_down: pass the triggering link through to etcp_on_down
3. etcp_update_log_name: always check registry for node_name
(n_5a1b... → SM-A525F when name is available in registry)
Add helper functions server_type_str() and nat_type_str() to convert
CFG_SERVER_TYPE_* and NAT_TYPE_* codes to readable names.
Now: Add Socket type=PUBLIC instead of type=1
self-detect check: type=PUBLIC nat=UNKNOWN instead of type=1 nat_type=0
- etcp_on_up: list up-link addresses after connection summary
- etcp_on_down: show all link addresses that were lost
- Link UP (server/client): add addr=X
- Connection established: add addr=X
- Link closed: add addr=X before traffic stats
- Link down (keepalive timeout): add addr=X
Now: [conn] Link 1 UP (server, mtu=1600, addr=192.168.40.247:2122)
- member_sync apply_items: empty payload is normal sync completion, not error
- topo_node_sqlite node_load: no addresses is normal for stub/seed nodes
- conn_mgr_core: node skipped when not in routing (normal for nodes w/o addrs)
- topo_group send_nodeinfo: downgrade ERROR→WARN in DEBUG category
- db_sync INIT_RESP: protocol details belong in DEBUG, not INFO
- stcp_server_create: support AF_INET and AF_INET6 V6ONLY=1 (no dual-stack)
- Add listen_family to stcp_link_config
- init_sockets: return error (not partial) on any bind failure
- add chat_core_sync_my_addresses() call at chatgui startup
- collect_my_addrs: add proto byte (1=UDP, 2=TCP) to binary format
- chat_sync.c JOIN/WELCOME/PEER_UPSERT: read proto byte, write protocol column
- member_sync.c: read proto byte, dynamic protocol bind
- topo_node.c: debug logs for nodeinfo changed detection
- node_config.cpp: type=public for all servers
- Replace instance->stcp_server (single pointer) with stcp_servers linked list
- Add stcp_server_list_add/destroy_all/count API in stcp_link.h/c
- Fix port extraction for both AF_INET and AF_INET6 in init_sockets
- Filter out 0.0.0.0 and [::] addresses in chat_profile.c TCP address sync
- Add type=public to servers in node_config.cpp saveFull()
- CONN_MGR entries: replace dynamic array with ll_queue (hash=256, key_size=8)
cm_find_entry now O(1) via queue_find_data_by_index
cm_ensure_entry uses queue_entry_new + queue_data_put_with_index
cm_entry_cleanup removes from queue and frees entry
- TOPO_GROUP_NODE: replace handles** array with single CONN_MGR_HANDLE*
remove topo_node_handle_register/unregister/count — dead indirection
nq->handle = h / nq->handle = NULL in all call sites
- TOPO_GROUP_NODE: remove dead fields dirty, best_socket, tranzit_data/count
dirty replaced with local variable in nat_detection.c
tranzit_data removed from wire format (TOPOMSG_NODE), serialize, deserialize
update struct layout: one field per line with comments
getifaddrs() ifa_flags contains interface flags (IFF_UP etc.), NOT address
flags (IFA_F_TEMPORARY). Since IFA_F_TEMPORARY == IFA_F_SECONDARY == 0x01,
and 0x01 in interface flags is IFF_UP, ALL addresses appeared as 'temporary',
making the permanent>temporary priority non-functional.
New netlink-based get_interface_ipv6_addr_nl() reads real IFA_FLAGS from
RTM_GETADDR response, correctly identifying:
- Temporary: IFA_F_TEMPORARY=1, IFA_F_MANAGETEMPADDR=0
- Stable/mngtmp: IFA_F_TEMPORARY=1, IFA_F_MANAGETEMPADDR=1
- Legacy static: IFA_F_TEMPORARY=0
Verified: wlo1 permanent (3a7a:eff:fef5:9637) now correctly selected
for prefer_stable=1, temporary (1fb5:b7c:7538:dcf4) for prefer_stable=0.
- CM_V6_ANY for :: socket (matches all v6 addr classes)
- sin6_scope_id from s->netif_index (not from local_addr where :: has scope=0)
- getnameinfo in stcp_link_connect to preserve scope_id in addr string
- scope_id in cm_invite_tcp_connect, ncd_create_links, connect_create_links_v6, cm_bg_ping_to_node
- ncd_down_cb: defer callback removal+close via uasync_call_soon to avoid
UAF in etcp_cbk_fire iteration (removing ncd_up_cb corrupts saved next ptr)
- ncd_recv_control_handler: use deferred close for CLOSE handlers instead of
direct etcp_connection_close to avoid nested etcp_cbk_fire UAF
- node_conn_direct_open/open_node: use ni->node_name if available for
conn name, fallback to 'n_<node_id>' instead of NULL
- init_connections: build ni_tmp in link loop with only current link's addr,
preventing NCD from creating links for ALL addrs on first socket
- utun_instance_reload: same per-link ni_tmp fix
- init_connections/reload: set ni_tmp.node_name = client->name for
test find_client_link by name
- chat_sync.c: move pending_invite clear from INFO_RESP to WELCOME,
post GUI_EVT_CONNECT_RESULT on invite success in cs_handle_welcome
- etcp_connections.c: NORM_DECRYPT_TRY/CRYPTO_DECRYPT_OK DEBUG_DEBUG->TRACE
- secure_channel.c: ENCRYPT/DECRYPT DEBUG_DEBUG->TRACE
- conn_mgr_init(TOPO_GROUP* group) — работает внутри заданной группы
- conn_mgr_connect_node: загрузка узла из SQLite если нет в BGP-таблице
- topo_node_sqlite_node_load(): загрузка TOPO_NODE (ref=0) из БД
- cm_start_phase_direct: db_loaded-ветка — перебор всех адресов без NAT-фильтра
- cm_cleanup_db_node: удаление TOPO_NODEQ из группы при неудаче, только если нет путей
- cm_start_phase_indirect: исправлено зависание при best_candidates==0 (cm_deliver_result)
- conn_mgr_set_direct_timeout_ms(): конфигурируемый таймаут фазы DIRECT
- conn_mgr_destroy до etcp_router_destroy (исправлен порядок)
- test_conn_mgr: +2 сценария (DB-успех, DB-недоступен), проверка topo_group
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.
- 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
- 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