Keep known-peer admission policy in the topology module
This commit is contained in:
1 parent
2923249b8e
commit
bd25e4abfc
2 files changed
+23
No files matched your search
@@ -409,6 +409,26 @@ static int topo_group_peer_allowed(struct TOPO_GROUP* group, uint64_t node_id) {
|
||||
return db && group->channel_id[0] && topo_node_sqlite_member_allowed(db, group->channel_id, node_id);
|
||||
}
|
||||
|
||||
/* Политика знакомого пира принадлежит группам/БД; транспорт передаёт только ключ, без SQL и таблиц. */
|
||||
int topo_groups_peer_key_known(struct UTUN_INSTANCE* inst, const uint8_t key[32]) {
|
||||
if (!inst || !key) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "known peer check: missing instance/key"); return 0; }
|
||||
if (!inst->topo_groups || !inst->topo_groups->group_list || !inst->topo_sqlite_db) {
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "known peer check: topology/database unavailable"); return 0;
|
||||
}
|
||||
for (struct ll_entry* e = inst->topo_groups->group_list->head; e; e = e->next) {
|
||||
struct TOPO_GROUP* g = (struct TOPO_GROUP*)e;
|
||||
if (!g->stopping && g->group_type == TOPO_GROUP_TYPE_CHAT && g->channel_id[0]
|
||||
&& topo_node_sqlite_member_key_allowed(inst->topo_sqlite_db, g->channel_id, key)) {
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "known peer admitted node=%016llx group=%016llx",
|
||||
(unsigned long long)sc_derive_node_id_from_pubkey(key), (unsigned long long)g->group_id);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "known peer denied node=%016llx reason=no active group membership",
|
||||
(unsigned long long)sc_derive_node_id_from_pubkey(key));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Приёмник BGP-пакетов от ETCP: диспетчер по subcmd (NODEINFO/WITHDRAW/...). */
|
||||
static void topo_group_receive_cbk(struct ETCP_CONN* from_conn, struct ll_entry* entry) {
|
||||
if (!entry) return;
|
||||
|
||||
@@ -280,6 +280,9 @@ struct TOPO_GROUPS {
|
||||
* @return TOPO_GROUPS или NULL при ошибке
|
||||
*/
|
||||
struct TOPO_GROUPS* topo_groups_init(struct UTUN_INSTANCE* instance);
|
||||
/* Только uasync. 1 — точный X25519-ключ действующего участника хотя бы одной своей CHAT-группы.
|
||||
* Без БД/групп, при SQL-ошибке, заглушке, удалённом мембере — 0. Объявления/реестр nodes не дают допуска. */
|
||||
int topo_groups_peer_key_known(struct UTUN_INSTANCE* instance, const uint8_t key[32]);
|
||||
|
||||
/**
|
||||
* @brief Обработчик события смены active mode (подписчик utun_add_activity_cbk).
|
||||
|
||||
Reference in new issue
Block a user