evgeny
7799d54c0c
conn_mgr: обновить API на единую точку входа conn_mgr_open_invite, поправить порядок destroy, обновить всех потребителей
...
- conn_mgr_cb_t: 5 параметров (h, node_id, group_id, event, arg)
- conn_mgr_open_invite: единая функция (ni=NULL — обычное, ni!=NULL — invite)
- CONN_EVENT_JOIN для успешного invite
- struct CONN_MGR_HANDLE: добавлен group_id
- bind/unbind в conn_mgr_init/destroy (один на инстанс, перезапись безвредна)
- utun_instance_destroy: conn_mgr_destroy до закрытия сокетов
- cm_ncd_callback: занулять ncd_handle при DOWN, защита от вызова после destroy
- topo_group_connect: свой трекинг handle'ов, conn_mgr_close для отмены
- обновлены: topo_recovery, media_download, media_delivery, chat_sync, тесты
2 months ago
evgeny
625382de34
node_conn_direct: add specific_sock param, move registry to per-instance; expose sc_hex_to_binary; add CONFIG_CONN_HANDLE
2 months ago
evgeny
8237d92be9
fix: NCD close UAF + conn name + init_connections per-link ni_tmp
...
- 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
2 months ago
evgeny
4ba4ab038c
cleanup: remove dead nd_handle from CONN_MGR_HANDLE, fix double semicolons in node_conn_direct, protect close from NULL conn
2 months ago
evgeny
eb2a8f6975
node_conn_direct: add open_node variant, refactor internals
2 months ago
evgeny
153483fd96
media_delivery: обновление и новый тест conn_mgr_handles
2 months ago
evgeny
d310bccf08
fix: memory pool alloc mismatch in tests, db_sync SEND_DATA buffer overflow
...
- test_etcp_router_reconnect, test_etcp_connect, test_stcp_traffic:
replace u_calloc with memory_pool_alloc for TOPO_SOCKMETA4/TOPO_ADDR4
- db_sync.c: fix req[14] -> req[15] — SEND_DATA request header is 15 bytes
(type:1 + from:4 + count:2 + vp:4 + want_from:4)
2 months ago
evgeny
fe9be74e29
topo refactoring (WIP): topo_node.h + AGENTS.md safety rules
2 months ago
evgeny
51d6c782ac
voice playback: miniaudio cursor ground truth + EMA smooth decay
...
- SoundManager: add currentPcmCursor()/isCurrentPcmPlaying() via ma_sound_get_cursor_in_pcm_frames / ma_sound_is_playing
- messagedelegate: replace wall-clock position tracking with real miniaudio cursor, remove 200ms hardcoded delay
- messagedelegate: end-of-playback detection via isCurrentPcmPlaying() instead of wall-clock comparison (was killing audio ~200ms early)
- messagedelegate: EMA smoothing of displayFrac/displayElapsed (0.15 factor, 16ms timer)
- messagedelegate: timer continues after audio stops to animate EMA decay to 0 (not mouse-move dependent)
- media_delivery: download progress callback, Ed25519 sig verify, author fallback, content hash check
- conn_mgr: already-connected returns OK with callback instead of error
- chatgui: voice download-pending auto-play, file download progress bar, media bar colors
2 months ago
evgeny
641c9f574f
db_sync: cascade insert + SYNC_DONE fixes + done_cbk + test stabilization
...
- db_record_insert_cascade: unified insert with on_insert + PUSH cascade
- SYNC_DONE moved from INIT_RESP to DATA handler (master sends after slave response)
- db_sync_add/remove_done_cbk: global sync-completion subscription (etcp pattern)
- REQUEST_SYNC handler: sync_state != 1 instead of == 0
- SYNC_DONE mc==pc hash mismatch: accept as converged
- Removed unconditional sync_state=2 from DATA handler
- test: done_cbk for sync phases, count-only for PUSH phases, removed dead B<>C reinitiate
2 months ago
evgeny
c093630d4d
db_sync: async batch chain_hash recalc (batch 50, timeout 0→100tb), flush before protocol chain_hash reads, remove db_cascade_from/range + do_cascade param
2 months ago
evgeny
df13b16fad
docs: AGENTS.md chat module descriptions, improved ETCP debug logging, android AGENTS update
2 months ago
evgeny
6f502243db
fix: etcp_conn_reset resume output_queue+ack_q+normalizer; collision client-timer cancel; ETCP full state dump to debug log on sync TIMEOUT
2 months ago
evgeny
a3b00984ed
fix: stable ETCP reconnect (no REINIT loop), own voice playback, peersOnline via conn state, UDP log diagnostics
2 months ago
evgeny
70797f921e
feature: media auto-download + manual download + UI download state indication (Android + desktop)
...
C-layer:
- chat_event.h: CHAT_EVT_ATTACHMENT_DOWNLOADED (14)
- chat_msg.c: fixed md_auto_download (non-NULL done_cb, correct media_base from db_path, use chat_setting for autoload checks)
- chat_msg.c: added chat_core_attachment_download + trampoline for manual download
- chat_core.h: exported attachment_dl_req + trampoline
Android (Kotlin + JNI):
- Message: downloadState field (parse from localAttrs)
- ChatRepository: parse localAttrs for download state
- NativeLib: attachmentDownload() JNI
- MessageBubble: FileBubble with download status icon + tap-to-download
- ChatViewModel: downloadAttachment() + CHAT_EVT_ATTACHMENT_DOWNLOADED handler
- ChatScreen: wire onDownloadFile handler
- android_jni_bridge: utun_bridge_attachment_download + JNI + localAttrs in JSON
Desktop (Qt/C++):
- messagedelegate.h: MsgFileDownloadStateRole, MsgChannelIdRole
- messagelist.cpp: parse localAttrs for file download state
- messagedelegate.cpp: FileBubble with download icon/text + click handler via chat_core_attachment_download_trampoline
- gui_bridge.h: GUI_EVT_ATTACHMENT_DOWNLOADED (14) + callback typedef
- gui_bridge_impl.cpp: event dispatch + setter
- mainwindow.cpp: callback registration -> refresh message list
2 months ago
evgeny
b8920cf483
chat_settings: [chat] config section + live sync + fix test segfault
...
- New chat_setting.c/h: unified chat settings API (int/str getters)
- Config parser supports [chat] section, calls chat_setting_set per key
- chat_core exposes chat_core_set_setting / trampoline for GUI bridge
- chatgui: AudioDevice + Storage pages persist to [chat] config + live apply
- chatgui-android: ConfigProvider, NativeLib, headless handle chat settings
- MessageList: 200 msg limit, fixed saveChannelState via trampoline
- test_media_delivery_full: fix segfault at shutdown (mon() timer vs freed conns)
2 months ago
evgeny
efbb495016
media_delivery: fix SUPER_REPL spam + streaming verification
...
Bugs fixed:
- md_super_peer_add: timeout_tb = 0 → MEDIA_REPL_TIMEOUT_TB (timer fired every poll)
- md_repl_retrans_cb: md from peer->connect_timer (garbage) → peer->md
- md_repl_retrans_cb: removed inflight_count=0 reset (don't resend acked entries)
- stream_ctx: removed unused block_data field (was NULL, caused crash in BLOCK_DONE)
Test improvements:
- stream_completed flag for reliable streaming verification
- File created in <db_dir>/media/ (matches media_index path logic)
- 9/9 full test, 33/33 total
2 months ago
evgeny
b4824de3b8
media_delivery: fix streaming crash, correct file path via media dir
...
- Fix NULL block_data deref in stream_send_chunk_cb
- Test B1: create file in <db_dir>/media/, commit to media_files
- Store media_base in ui_state for streaming handler path resolution
- 8/9 tests pass (streaming works but timing issue with SUPER_REPL flood)
2 months ago
evgeny
a6321e15b3
media_delivery: streaming, fallback, admission control, 8/9 tests
...
- md_handle_block_req: real chunk streaming via etcp_router_on_send_ready
- stream_ctx state machine: backpressure waiter → send chunk → repeat
- content_hash + block_sig on stream completion
- Fallback to author when supernode has no block info
- media_download: author_node_id for peer fallback
- test_media_delivery_full: 8/9 pass (SUPER_HELLO, HAVE_BLOCK, replication, admission, file create)
- Known issue: streaming test hung (BGP route for n1→n2 not established in time)
2 months ago
evgeny
57e6ffed16
media_delivery: admission control + OVERLOADED + full integration test
...
- MEDIA_BLOCK_OVERLOADED (0x0F) subcommand + packed struct
- Admission control: track active_streams, reject > 3 with OVERLOADED
- media_delivery_stream_done() to decrement counter after stream finish
- Auto-download trigger in chat_msg.c (parse media metadata, check settings)
- test_media_delivery_full.c: 9/9 tests on 4 instances
(SUPER_HELLO, HAVE_BLOCK, replication, admission control, OVERLOADED)
- All 33 existing tests still pass (15+5+4+9)
2 months ago
evgeny
5e739176fa
media_delivery: fix etcp_route_send svc_id + integration test
...
Root cause: etcp_route_send reads dgram[0] as svc_id, not subcmd.
router_deliver prepends svc_id byte on receive.
Fixes:
- md_send/md_dl_send/msend: prepend ETCP_RT_ID_MEDIA_DELIVERY to dgram[0]
- md_etcp_recv: read subcmd from data[1] (was data[0])
- etcp_api.h: document dgram[0]=svc_id convention
- media_delivery_set_supernode(): public API for dynamic switching
Tests:
- test_media_delivery_integration: 4/4 (SERVE_REG, HAVE_BLOCK, supernode stop/start)
- All 24 existing tests still pass
2 months ago
evgeny
a863da7737
media_delivery: add tests + fix queue_new NULL ua and index_offset bugs
...
- test_media_delivery_sql: 15 tests (SQL tables, CRUD, packed structs)
- test_media_delivery_download: 5 tests (chunk write/append, sig verify, assembly, cancel)
- Fix: queue_new(NULL) returns NULL — pass inst->ua everywhere
- Fix: queue index offset must be offsetof(struct, key_field) not 0
- Move struct media_download to header for test visibility
2 months ago
evgeny
fb3e34080d
media_delivery: implement full media delivery subsystem (stages 1-8)
...
- topo_group: add BGP node event callbacks (NEW/UPDATE/REMOVE)
- member_sync: add multi-subscriber node_props_changed callback (adm_tags)
- media_delivery: SQLite tables (block_availability + super_sync), full protocol handler
- media_delivery_proto.h: packed protocol structures (15 subcommands)
- media_download: download management, chunk streaming, block assembly, HAVE_BLOCK with retry
- Makefile.am: add media_download.c to builds
2 months ago
evgeny
7d9cbad8c5
media_delivery: add architecture description and implementation plan
2 months ago
evgeny
65dbfa6813
feat: media_async + media_index modules, media_files table, tests
...
- media_async: thread-per-task async engine with primitives (sha256, sign, copy, uuid, file_size)
- media_index: media_files DB table with register_async for indexing chunks
- chat_msg: async media submission via register_async, simplified chat_msg_submit fields
- voice_recorder/attachment_sender: write single file (no chunk splitting on caller side)
- inputbar/messagelist: updated to new simplified submit interface
- test_media_async: 4-thread stress test (200K ops / 2 sec, 0 errors)
- test_media_index: 9 cases covering commit edge cases + async flow
- build: Makefile.am, CMakeLists.txt, utun_sources.cmake updated
2 months ago
evgeny
ce5a84da24
fix: uasync epoll event ordering + test_uasync_socket_race fix
2 months ago
evgeny
3c75c8f687
icons: replace emoji text with PNG resources + add media_dir debug logs
2 months ago
evgeny
39d6f19d97
fix: chat_msg media_dir path — strip filename from g_cc.db_path
...
g_cc.db_path is '/data/.../files/chats.db' (file path), but media blocks
are written to '/data/.../files/media/<channel>/'. chat_msg was concatenating
'chats.db/media/...' — now strips the database filename, using only the
directory portion for the media path.
2 months ago
evgeny
e751e6ee69
android: voice messages + attachments architecture plan, build fixes
2 months ago
evgeny
f8d7c21a79
Android: unify DB access via JNI/JSON, fix instance lifecycle, add restart + health check
...
- ChatRepository: remove SQLiteDatabase (READONLY 2nd handle), use JNI→shared g_cc.db (FULLMUTEX, like desktop)
- instance_lite: simplify start/stop lifecycle — start no longer waits for init, stop waits for thread exit with timeout, add internal restart (no thread kill)
- Restart trampoline: reinit UDP log target on config change
- Health check: ping/uasync_post round-trip every 3s, red dot on stall
- Settings: Restart instance button
- Fix: g_inst check instead of g_running for is_running()
- Fix: SharedFlow replay=1 + proactive DB_READY check in ViewModel
2 months ago
evgeny
03b34e9580
android: fix QR join flow + cleanup log levels + remove log artifacts
...
- MainActivity: call NativeLib.joinChannel directly (bypass ViewModel null repo)
- LogManager: add Log.d for Kotlin logs visibility in logcat
- ChatViewModel/NativeLib: add diagnostic logs for join path
- chat_sync: JNI-safe logs via __android_log_print, add error on !g_cs
- etcp_debug: DUMP INFO→DEBUG (remove 99.8% packet spam)
- secure_channel/etcp_connections/topo_node: keepalive PING/PONG spam INFO→DEBUG
- .gitignore: logreceiver output + build artifacts
- Remove tracked log files and build dir from repo
2 months ago
evgeny
0216b0bf50
android: utun shutdown diagnostics + non-blocking stop + logreceiver doc
...
- instance_lite: cleanup moved to uasync thread (self-detach), events on start/stop
- udp_log: cancel_timer before uasync_destroy, flush on stop, stopping flag
- jni_bridge: fixed UDP stop order (cancel_timer → destroy → flush)
- instance_lite: u_report_unfreed_blocks at all shutdown paths
- chat_event: CHAT_EVT_SERVICE_STARTED/STOPPED for GUI notifications
- AGENTS: logreceiver section
2 months ago
evgeny
064bed06f2
android: fix key regeneration, Clear DB, uasync eventfd, udp log from config
...
- jni_on_event: fix JNI_EDETACHED — AttachCurrentThread/DetachCurrentThread
- u_async.c: pipe→eventfd for reliable cross-thread wakeup
add process_posted_tasks in poll() path, fix EINTR (saved_errno)
- bridge_debug_hook: keep udp_log_write, remove mutex from udp_log
- memory_pool.c: alloc/free logs INFO→DEBUG (reduce spam)
- instance_lite.c: chat_event_set_handler before ensure_keys,
KEYS_GENERATED events, fchmod 0600 on keys.conf,
UDP log from config [log_udp] section, regenerate_trampoline
- config_parser: parse [log_udp] ip/port
- NativeLib.kt: remove callbacksSet, simplify init/stop/destroy
- ChatViewModel.kt: unified event callback in init, pubKey StateFlow,
requestRegenerateKeys, clearState fix
- SettingsScreen.kt: pubKey.collectAsState(), Clear DB via restart()
- HeadlessService.kt: remove setUdpLogTarget (now from config)
- android_udp_log.c: simplified — no mutex, buffer+send+timer in one thread
- utun_instance.c: NULL-check tcp_connections before destroy
- chat_event.h: +CHAT_EVT_KEYS_GENERATED 11, -NODE_CHANGED
- logreceiver: UDP log receiver tool
2 months ago
evgeny
d0cca27edd
invite: add proto field (UDP/TCP/BOTH) to invite link binary format
...
Format per v4 addr: family(1) + socketId(1) + proto(1) + addr(4) + port(2) = 9 bytes (was 8)
Proto values: 0x01=UDP, 0x02=TCP, 0x03=BOTH
Affects: invite_link_c.h/c (Android), invite_link.h/cpp (desktop), chat_sync.c, conn_mgr.c, joindialog.cpp, utun_node.cpp
2 months ago
Evgeny
d1f6f6fca9
fix WELCOME deserialization: skip atl+adm_tags_sig fields before address data
2 months ago
Evgeny
2d53b3120f
ffmpeg: add build script and CMake integration
2 months ago
Evgeny
d4a396f888
media: Ed25519-подписи блоков, local_attrs, MediaBlockReader, файловые вложения
2 months ago
Evgeny
ed6132fcda
перенос chat-логики из chatgui/transport в src/chat/
...
- Создан src/chat/ с chat_event.h/c — система нотификаций
- Перенесены chat_core, chat_msg, chat_channel, chat_profile, chat_status
- Перенесены chat_sync, member_sync, merkle_sync, db_sync
- gui_bridge_post() заменён на chat_event_post() с возможностью регистрации обработчика
- chat_event_set_handler() — chatgui регистрирует мост в gui_bridge
- Без обработчика: события логируются через DEBUG_DEBUG + log_dump
- chat интегрирован в utun_instance.c (при db_path в конфиге)
- Обновлены include-пути, Makefile.am, CMakeLists.txt
- Из chatgui удалены старые transport/ файлы, обновлён utun_node.cpp
2 months ago
Evgeny
4fde0b0325
feat: integrate Opus codec into lib/libopus + voice messages in chatgui
...
- Add lib/libopus/ (opus v1.6.1 embedded source: CELT 18 .c, SILK 77 .c, SILK float 28 .c, OPUS core 14 .c)
- Add lib/opus_codec.h/.c (wrapper: encoder, decoder, raw PCM int16)
- Add tests/test_opus_codec.c (7 tests: silence, sine, compression, PLC, null, defaults, multi-frame)
- chatgui: AudioRecorder (miniaudio capture, 48kHz mono)
- chatgui: VoiceEncoder (PCM→Opus file with custom container)
- chatgui: VoicePlayer (Opus→PCM playback via SoundManager)
- chatgui: PTT button in InputBar, voice message send/receive in MessageList
- chatgui: AudioDeviceSettingsPage (device selection, persisted in ui_state)
- chatgui: MessageDelegate voice message rendering (play button + duration)
- Update autotools: configure.ac, Makefile.am, src/Makefile.am, tests/Makefile.am
- Update CMake: chatgui CMakeLists.txt, libutun CMakeLists.txt (link libopus_internal.a)
2 months ago
Evgeny
a1ecab997e
merkle_sync: fix 4 protocol bugs + add test suite (Stages 1-4)
...
- g_merkle singleton → per-instance msync (utun_instance.h)
- level_prefix: off-by-one shift (63→64)
- _handle_hashes: differs |= for shared buckets with different hashes
- _handle_batch: sub_pl double-level-offset (next_lvl→lvl)
- pending[] array replaces pending_requests counter
- member_sync: mask_shift 63→64 alignment
- test_merkle_sync.c: prefix arithmetic, tree building, 2-instance integration, randomized 50-iter sync
2 months ago
Evgeny
49da899964
chatgui: channel sorting by name or last message time with preview
...
- Add last_msg_at column to channels table
- Update last_msg_at on every message insert (send/receive)
- Parameterize getChannels() with ChannelSortMode enum (Alphabetical/Recent)
- Add getChannelLastMessage() for preview text in channel list
- Add sorting combo to Profile settings page (stored in ui_state)
- Reload channels on message receive when sort is recent
2 months ago
Evgeny
22db84816e
chatgui: add local_nick TEXT to peers table DDL, remove ALTER TABLE hacks
2 months ago
Evgeny
11ab897fe5
chatgui: fix RTT display 10x overstatement (DB stores 0.1ms, displayed as ms); remove unused rtt_avg_100
2 months ago
Evgeny
ecb03ca290
conn_mgr: detect duplicate conn in handshake; etcp: loud collision errors in link/peer_id
2 months ago
Evgeny
7a9e3bea5f
db_sync: mc>pc guard with last_peer_count — detect stalled sync when pc doesn't change
2 months ago
Evgeny
3490789249
db_sync: skip SYNC_DONE in count>0 handler when received==0 — breaks bad_sig recv→send loop on client side
2 months ago
Evgeny
c9436219a0
db_sync: fix synced_pos overwrite in SYNC_DONE — use max to preserve total_processed advance
2 months ago
Evgeny
34404403ef
db_sync: verify sig before send + fix total_processed double-count
2 months ago
Evgeny
e9fce43be5
db_sync: fix bad_sig infinite loop — delete+rechain, advance synced_pos past dup/bad_sig, accept on covered tail
2 months ago
Evgeny
27906e9f91
db_sync: односторонний sync, sparse-таблица, vp в SEND_DATA, PUSH-релей
2 months ago