Separate core, UTUN and chat lifecycles with owned asynchronous work
This commit is contained in:
1 parent
5838e63cde
commit
72fee9e245
47 files changed
+708
-337
No files matched your search
@@ -192,6 +192,7 @@ void topo_nodeq_free_group_fields(struct TOPO_GROUPS* groups, struct TOPO_GROUP_
|
||||
void topo_nodeq_remove_node(struct TOPO_GROUP* group, struct TOPO_GROUP_NODE* nq) {
|
||||
if (!group || !nq) return;
|
||||
route_connectivity_cancel_node(nq);
|
||||
if (group->instance) route_delete(group->instance->rt, nq);
|
||||
if (nq->paths) { queue_free(nq->paths); nq->paths = NULL; }
|
||||
queue_remove_data(group->nodes, &nq->ll);
|
||||
topo_nodeq_free_group_fields(group->instance ? group->instance->topo_groups : NULL, nq);
|
||||
@@ -928,6 +929,25 @@ int topo_node_format_all(struct TOPO_GROUP* group, char* buf, size_t buf_size) {
|
||||
|
||||
// ===== update my nodeinfo =====
|
||||
|
||||
/* Core owns one reference independently of all services. */
|
||||
int topo_node_init_self(struct UTUN_INSTANCE* instance) {
|
||||
struct TOPO_NODE* ni = u_calloc(1, sizeof(*ni));
|
||||
if (!ni) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "local identity allocation failed"); return -1; }
|
||||
ni->node_id = instance->node_id; ni->ver = 1;
|
||||
ni->client_type = instance->client_type; ni->client_activity = instance->client_activity;
|
||||
memcpy(ni->public_key, instance->my_keys.public_key, SC_PUBKEY_SIZE);
|
||||
memcpy(ni->ed25519_public_key, instance->my_ed25519_pubkey, SC_PUBKEY_SIZE);
|
||||
ni->node_name = u_strdup(instance->name);
|
||||
if (!ni->node_name || topo_node_sign_self(instance, ni) < 0) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_BGP, "cannot initialize local identity");
|
||||
topo_node_destroy(instance->topo_groups, ni); return -1;
|
||||
}
|
||||
if (!topo_node_registry_store(instance->topo_groups, ni)) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_BGP, "cannot register local identity"); return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Пересоздаёт local_node группы при изменении имени/подсетей/ключей, инкрементируя версию. */
|
||||
int topo_group_update_my_nodeinfo(struct UTUN_INSTANCE* instance, struct TOPO_GROUP* group) {
|
||||
if (!instance || !group) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "invalid args"); return -1; }
|
||||
@@ -1039,8 +1059,6 @@ int topo_group_update_my_nodeinfo(struct UTUN_INSTANCE* instance, struct TOPO_GR
|
||||
/* Пересобирает списки адресов своего узла из ETCP-сокетов; при изменении — подпись, БД, рассылка. */
|
||||
int topo_node_update_my_addresses(struct UTUN_INSTANCE* instance) {
|
||||
if (!instance || !instance->topo_groups) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "invalid args"); return -1; }
|
||||
struct TOPO_GROUP* default_group = topo_groups_get_default(instance->topo_groups);
|
||||
if (!default_group || !default_group->local_node) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "no local_node"); return -1; }
|
||||
struct TOPO_NODE* ni = topo_node_registry_find(instance->topo_groups, instance->node_id);
|
||||
if (!ni) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "my node not in registry"); return -1; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user