fix: invite не затирает имя узла, имя читается из member_sync peers.userinfo
- conn_mgr_core.c: убрана запись node_name из cm_handle_invite_info_resp - topo_node_sqlite.c: name в nodes не перезаписывается пустой строкой - android_jni_bridge.c: bridge_get_node_name читает peers_<ch>.userinfo если nodes.name пуст
This commit is contained in:
1 parent
253129cb27
commit
e1e54df4f4
14 files changed
+234
-125
No files matched your search
@@ -58,6 +58,10 @@ static void cm_deliver_up_cb(void* arg) {
|
||||
* Все поля handle'а читаются до вызова коллбэка — коллбэк может закрыть
|
||||
* handle (conn_mgr_close), после вызова к handle не обращаемся. */
|
||||
void cm_deliver_event(struct CONN_MGR_ENTRY* entry, enum conn_mgr_event event) {
|
||||
if (!entry || !entry->mgr || !entry->mgr->group) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_GENERAL, "cm_deliver_event: BAD entry=%p mgr=%p", entry, entry ? (void*)entry->mgr : NULL);
|
||||
return;
|
||||
}
|
||||
uint64_t gid = entry->mgr->group->group_id;
|
||||
struct CONN_MGR_HANDLE* h = entry->handles;
|
||||
while (h) {
|
||||
@@ -221,7 +225,7 @@ void cm_update_nodeinfo(struct CONN_MGR_ENTRY* entry) {
|
||||
}
|
||||
|
||||
void cm_cleanup_db_node(struct CONN_MGR_ENTRY* entry) {
|
||||
if (!entry->db_loaded) return;
|
||||
if (!entry || !entry->mgr || !entry->mgr->group || !entry->db_loaded) return;
|
||||
struct TOPO_GROUP* group = entry->mgr->group;
|
||||
struct TOPO_GROUP_NODE* nq = topo_node_find_by_id(group, entry->node_id);
|
||||
if (!nq) return;
|
||||
@@ -243,7 +247,7 @@ void cm_cleanup_db_node(struct CONN_MGR_ENTRY* entry) {
|
||||
* DOWN — соединение упало, доставляем DOWN. */
|
||||
void cm_ncd_callback(struct NODE_CONN_DIRECT* ncd_h, enum ncd_event ncd_ev, void* arg) {
|
||||
struct CONN_MGR_ENTRY* entry = (struct CONN_MGR_ENTRY*)arg; (void)ncd_h;
|
||||
if (entry->state == CONN_MGR_STATE_DISCONNECTED) return;
|
||||
if (!entry || !entry->mgr || entry->state == CONN_MGR_STATE_DISCONNECTED) return;
|
||||
switch (ncd_ev) {
|
||||
case NCD_EVENT_UP:
|
||||
if (entry->state == CONN_MGR_STATE_CONNECTED) return;
|
||||
@@ -255,13 +259,17 @@ void cm_ncd_callback(struct NODE_CONN_DIRECT* ncd_h, enum ncd_event ncd_ev, void
|
||||
cm_update_nodeinfo(entry); cm_deliver_event(entry, CONN_EVENT_UP);
|
||||
break;
|
||||
case NCD_EVENT_TIMEOUT:
|
||||
DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "link: ETCP connect TIMEOUT to 0x%016llx — no response, trying fallback",
|
||||
(unsigned long long)entry->node_id);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "link: ETCP connect TIMEOUT to 0x%016llx — entry=%p mgr=%p db_loaded=%d",
|
||||
(unsigned long long)entry->node_id, entry, (void*)entry->mgr, entry->db_loaded);
|
||||
if (entry->db_loaded) {
|
||||
entry->main_connect_state = CM_TRY_FAILED;
|
||||
{ struct NODE_CONN_DIRECT* ncd = entry->ncd_handle; entry->ncd_handle = NULL;
|
||||
if (ncd) node_conn_direct_force_close(ncd); }
|
||||
cm_cleanup_db_node(entry); cm_deliver_event(entry, CONN_EVENT_TIMEOUT);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "link: TIMEOUT after force_close, calling cleanup");
|
||||
cm_cleanup_db_node(entry);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "link: TIMEOUT after cleanup, calling deliver");
|
||||
cm_deliver_event(entry, CONN_EVENT_TIMEOUT);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "link: TIMEOUT done");
|
||||
return;
|
||||
}
|
||||
entry->main_connect_state = CM_TRY_FAILED;
|
||||
@@ -774,9 +782,7 @@ void cm_handle_invite_info_resp(struct CONN_MGR* mgr, struct ETCP_CONN* conn, co
|
||||
}
|
||||
if (inv->temp_nq) {
|
||||
struct TOPO_NODE* ni2 = topo_node_registry_find(inv->mgr->instance->topo_groups, inv->temp_nq->node_id);
|
||||
if (ni2) { memcpy(ni2->ed25519_public_key, resp->ed25519_pubkey, SC_PUBKEY_SIZE);
|
||||
if (ni2->node_name) { u_free(ni2->node_name); ni2->node_name = NULL; }
|
||||
if (resp->node_name_len) ni2->node_name = u_strdup((const char*)resp->node_name); }
|
||||
if (ni2) memcpy(ni2->ed25519_public_key, resp->ed25519_pubkey, SC_PUBKEY_SIZE);
|
||||
if (inv->mgr->instance->topo_sqlite_db) topo_node_sqlite_node_put(inv->mgr->instance->topo_sqlite_db, inv->mgr->instance->topo_groups, inv->temp_nq, (time_t)(get_time_tb()/10000));
|
||||
}
|
||||
if (inv->overall_timer) { uasync_cancel_timeout(inv->mgr->instance->ua, inv->overall_timer); inv->overall_timer = NULL; }
|
||||
|
||||
@@ -249,10 +249,9 @@ static void topo_group_destroy(struct TOPO_GROUP* group) {
|
||||
while ((e = queue_data_get(group->senders_list)) != NULL) queue_entry_free(e);
|
||||
queue_free(group->senders_list);
|
||||
|
||||
if (group->local_node) { topo_nodeq_free_group_fields(group->instance->topo_groups, group->local_node); u_free(group->local_node); }
|
||||
|
||||
if (group->conn_mgr) { conn_mgr_destroy(group->conn_mgr); group->conn_mgr = NULL; }
|
||||
if (group->nodes) queue_free(group->nodes);
|
||||
group->conn_mgr = NULL; /* destroyed externally in utun_instance_destroy before etcp_router_destroy */
|
||||
if (group->local_node) { topo_nodeq_free_group_fields(group->instance->topo_groups, group->local_node); u_free(group->local_node); }
|
||||
}
|
||||
|
||||
struct TOPO_GROUPS* topo_groups_init(struct UTUN_INSTANCE* instance) {
|
||||
|
||||
@@ -119,7 +119,7 @@ int topo_node_sqlite_node_put(sqlite3* db, struct TOPO_GROUPS* groups, struct TO
|
||||
"INSERT INTO nodes(node_id, name, x25519_pubkey, ed25519_pubkey, last_seen_at)"
|
||||
" VALUES(?,?,?,?,?)"
|
||||
" ON CONFLICT(node_id) DO UPDATE SET"
|
||||
" name=excluded.name, x25519_pubkey=excluded.x25519_pubkey,"
|
||||
" name=CASE WHEN excluded.name != '' THEN excluded.name ELSE nodes.name END, x25519_pubkey=excluded.x25519_pubkey,"
|
||||
" ed25519_pubkey=excluded.ed25519_pubkey, last_seen_at=excluded.last_seen_at,\n"
|
||||
" created_at=COALESCE(nodes.created_at, excluded.created_at)",
|
||||
-1, &stmt, NULL) == SQLITE_OK) {
|
||||
|
||||
Reference in new issue
Block a user