Require active complete membership for CHAT group admission
This commit is contained in:
1 parent
18c18d8338
commit
6317916e13
3 files changed
+23
-2
No files matched your search
@@ -841,6 +841,23 @@ int topo_node_sqlite_member_in_channel(sqlite3* db, const char* channel_id, uint
|
||||
return found;
|
||||
}
|
||||
|
||||
int topo_node_sqlite_member_allowed(sqlite3* db, const char* channel_id, uint64_t node_id) {
|
||||
if (!db || !channel_id || !channel_id[0] || !node_id) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_BGP, "member admission: invalid channel/node"); return 0;
|
||||
}
|
||||
char table[80], sql[256]; peers_table_name(channel_id, table, sizeof(table));
|
||||
snprintf(sql, sizeof(sql), "SELECT 1 FROM \"%s\" WHERE node_id=? AND source=0 AND deleted=0", table);
|
||||
sqlite3_stmt* statement = NULL;
|
||||
int rc = sqlite3_prepare_v2(db, sql, -1, &statement, NULL);
|
||||
if (rc == SQLITE_OK) rc = sqlite3_bind_int64(statement, 1, (sqlite3_int64)node_id);
|
||||
if (rc == SQLITE_OK) rc = sqlite3_step(statement);
|
||||
int allowed = rc == SQLITE_ROW;
|
||||
if (rc != SQLITE_ROW && rc != SQLITE_DONE)
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_BGP, "member admission read failed channel=%s node=%016llx rc=%d: %s",
|
||||
channel_id, (unsigned long long)node_id, rc, sqlite3_errmsg(db));
|
||||
sqlite3_finalize(statement); return allowed;
|
||||
}
|
||||
|
||||
int topo_node_sqlite_member_del(sqlite3* db, const char* channel_id, uint64_t node_id) {
|
||||
if (!db || !channel_id) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "member delete: invalid arguments"); return -1; }
|
||||
char peers_tbl[80]; peers_table_name(channel_id, peers_tbl, sizeof(peers_tbl));
|
||||
@@ -1370,7 +1387,7 @@ int topo_node_sqlite_get_connect_peers(sqlite3* db, const char* channel_id,
|
||||
char sql[512];
|
||||
snprintf(sql, sizeof(sql),
|
||||
"SELECT p.node_id,p.adm_tags,s.timestamp,s.record FROM \"%s\" p"
|
||||
" LEFT JOIN node_snapshots s ON s.node_id=p.node_id WHERE p.deleted=0"
|
||||
" LEFT JOIN node_snapshots s ON s.node_id=p.node_id WHERE p.deleted=0 AND p.source=0"
|
||||
" ORDER BY p.connected DESC,p.node_RTT IS NULL,p.node_RTT,p.node_id", table);
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
int rc = sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);
|
||||
|
||||
Reference in new issue
Block a user