dm: прямой обмен сообщениями (DM) + soundtouch + архитектура звонков
- src/dm/: dm_core/dm_crypto/dm_mailbox — прямой обмен сообщениями (DM) - lib/soundtouch-master/: vendored SoundTouch (изменение темпа/высоты аудио) - doc/dm_arch.md, doc/chat_call_arch.md: архитектура DM и звонков - tests: test_dm.c, test_dm_e2e.c - chat: рефакторинг chat_* модулей, member_sync, invite_build - chatgui/chatgui-android: синхронизация с новым API чата - lib/u_async, debug_config, utun_instance: сопутствующие изменения
This commit is contained in:
1 parent
761f64cf76
commit
73fe99b33f
123 files changed
+14095
-1270
No files matched your search
+11
-9
@@ -49,7 +49,8 @@ static void admin_key_recv_cb(struct ETCP_CONN* conn, struct ll_entry* entry) {
|
||||
}
|
||||
struct UTUN_INSTANCE* inst = conn->instance;
|
||||
if (!inst) { queue_dgram_free(entry); queue_entry_free(entry); return; }
|
||||
if (!g_cc.initialized || !g_cc.db) { queue_dgram_free(entry); queue_entry_free(entry); return; }
|
||||
struct chat_core_ctx* cc = CC(inst);
|
||||
if (!cc || !cc->initialized || !cc->db) { queue_dgram_free(entry); queue_entry_free(entry); return; }
|
||||
|
||||
const uint8_t* d = entry->dgram;
|
||||
uint64_t from_node;
|
||||
@@ -64,7 +65,7 @@ static void admin_key_recv_cb(struct ETCP_CONN* conn, struct ll_entry* entry) {
|
||||
|
||||
/* проверить, что ключи соответствуют публичным ключам канала (защита от подлога) */
|
||||
uint8_t ch_x_pub[32], ch_ed_pub[32];
|
||||
if (topo_node_sqlite_channel_get(g_cc.db, ch_id, NULL, 0, NULL, ch_x_pub, ch_ed_pub, NULL) != 0) {
|
||||
if (topo_node_sqlite_channel_get(cc->db, ch_id, NULL, 0, NULL, ch_x_pub, ch_ed_pub, NULL) != 0) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: recv — no channel ch=%s from 0x%016llx, drop",
|
||||
CA_ID, ch_id, (unsigned long long)from_node);
|
||||
queue_dgram_free(entry); queue_entry_free(entry); return;
|
||||
@@ -80,7 +81,7 @@ static void admin_key_recv_cb(struct ETCP_CONN* conn, struct ll_entry* entry) {
|
||||
queue_dgram_free(entry); queue_entry_free(entry); return;
|
||||
}
|
||||
|
||||
if (topo_node_sqlite_channel_set_privs(g_cc.db, ch_id, x_priv, ed_priv) != 0) {
|
||||
if (topo_node_sqlite_channel_set_privs(cc->db, ch_id, x_priv, ed_priv) != 0) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: recv — set_privs FAILED ch=%s from 0x%016llx",
|
||||
CA_ID, ch_id, (unsigned long long)from_node);
|
||||
queue_dgram_free(entry); queue_entry_free(entry); return;
|
||||
@@ -93,7 +94,7 @@ static void admin_key_recv_cb(struct ETCP_CONN* conn, struct ll_entry* entry) {
|
||||
uint8_t cl = (uint8_t)strlen(ch_id);
|
||||
evt[0] = cl; memcpy(evt + 1, ch_id, cl);
|
||||
memcpy(evt + 1 + cl, &from_node, 8);
|
||||
chat_event_post(CHAT_EVT_ADMIN_KEY_RECEIVED, evt, 1 + cl + 8);
|
||||
chat_event_post(inst, CHAT_EVT_ADMIN_KEY_RECEIVED, evt, 1 + cl + 8);
|
||||
|
||||
queue_dgram_free(entry); queue_entry_free(entry);
|
||||
}
|
||||
@@ -118,8 +119,9 @@ void chat_admin_destroy(struct UTUN_INSTANCE* inst) {
|
||||
|
||||
/* ─── передача прав (вызывается из uasync-потока) ─── */
|
||||
|
||||
void chat_core_transfer_admin(const char* ch_id, uint64_t target_node_id) {
|
||||
if (!g_cc.initialized || !g_cc.inst || !g_cc.db) {
|
||||
void chat_core_transfer_admin(struct UTUN_INSTANCE* inst, const char* ch_id, uint64_t target_node_id) {
|
||||
struct chat_core_ctx* cc = CC(inst);
|
||||
if (!cc || !cc->initialized || !inst || !cc->db) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: transfer — not initialized", CA_ID);
|
||||
return;
|
||||
}
|
||||
@@ -130,7 +132,7 @@ void chat_core_transfer_admin(const char* ch_id, uint64_t target_node_id) {
|
||||
}
|
||||
|
||||
uint8_t x_priv[32], ed_priv[32];
|
||||
if (topo_node_sqlite_channel_get_privs(g_cc.db, ch_id, x_priv, ed_priv) != 0) {
|
||||
if (topo_node_sqlite_channel_get_privs(cc->db, ch_id, x_priv, ed_priv) != 0) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: transfer — no channel privkey ch=%s (not owner?)", CA_ID, ch_id);
|
||||
return;
|
||||
}
|
||||
@@ -154,7 +156,7 @@ void chat_core_transfer_admin(const char* ch_id, uint64_t target_node_id) {
|
||||
memcpy(entry->dgram + 1, payload, sizeof(payload));
|
||||
entry->len = 1 + (uint16_t)sizeof(payload);
|
||||
|
||||
int rc = etcp_route_send(g_cc.inst, group_id, target_node_id, entry, 1,
|
||||
int rc = etcp_route_send(inst, group_id, target_node_id, entry, 1,
|
||||
ROUTE_CRYPTO_SIGN | ROUTE_CRYPTO_ENCRYPT);
|
||||
if (rc != 0) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: transfer — etcp_route_send FAILED rc=%d ch=%s → 0x%016llx",
|
||||
@@ -169,6 +171,6 @@ void chat_core_transfer_admin(const char* ch_id, uint64_t target_node_id) {
|
||||
void chat_core_transfer_admin_trampoline(void* arg) {
|
||||
struct chat_transfer_admin_req* req = (struct chat_transfer_admin_req*)arg;
|
||||
if (!req) return;
|
||||
chat_core_transfer_admin(req->ch_id, req->target_node_id);
|
||||
chat_core_transfer_admin(req->inst, req->ch_id, req->target_node_id);
|
||||
u_free(req);
|
||||
}
|
||||
Reference in new issue
Block a user