do not permit node id to be a schema member. closes #359

This commit is contained in:
Christien Rioux 2024-03-07 22:32:19 -05:00
parent d8710b800d
commit ab419f03ef
2 changed files with 20 additions and 3 deletions

View File

@ -212,6 +212,20 @@ impl StorageManagerInner {
apibail_not_initialized!();
};
// Verify the dht schema does not contain the node id
{
let cfg = self.unlocked_inner.config.get();
if let Some(node_id) = cfg.network.routing_table.node_id.get(kind) {
if schema.is_member(&node_id.value) {
apibail_invalid_argument!(
"node id can not be schema member",
"schema",
node_id.value
);
}
}
}
// Compile the dht schema
let schema_data = schema.compile();

View File

@ -134,8 +134,11 @@ fn get_route_id(
}
}
fn get_dht_schema(text: &str) -> Option<DHTSchema> {
deserialize_json::<DHTSchema>(text).ok()
fn get_dht_schema(text: &str) -> Option<VeilidAPIResult<DHTSchema>> {
if text.is_empty() {
return None;
}
Some(deserialize_json::<DHTSchema>(text))
}
fn get_safety_selection(routing_table: RoutingTable) -> impl Fn(&str) -> Option<SafetySelection> {
@ -1424,7 +1427,7 @@ impl VeilidAPI {
"dht_schema",
get_dht_schema,
)
.unwrap_or_else(|_| DHTSchema::dflt(1));
.unwrap_or_else(|_| Ok(DHTSchema::dflt(1)))?;
let csv = get_debug_argument_at(
&args,