diff --git a/.vscode/launch.json b/.vscode/launch.json index 07ea4a8b..f8f9a1d2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -75,6 +75,7 @@ "args": [ "test", "--no-run", + "--features=rt-tokio", "--manifest-path", "veilid-core/Cargo.toml" ], diff --git a/veilid-core/src/tests/common/test_veilid_config.rs b/veilid-core/src/tests/common/test_veilid_config.rs index 31af8b1f..b7a511a9 100644 --- a/veilid-core/src/tests/common/test_veilid_config.rs +++ b/veilid-core/src/tests/common/test_veilid_config.rs @@ -192,17 +192,8 @@ fn config_callback(key: String) -> ConfigCallbackReturn { "network.client_whitelist_timeout_ms" => Ok(Box::new(300_000u32)), "network.reverse_connection_receipt_time_ms" => Ok(Box::new(5_000u32)), "network.hole_punch_receipt_time_ms" => Ok(Box::new(5_000u32)), - "network.routing_table.node_ids" => { - let mut nids = BTreeMap::::new(); - nids.insert( - CRYPTO_KIND_VLD0, - VeilidConfigNodeId { - node_id: None, - node_id_secret: None, - }, - ); - Ok(Box::new(nids)) - } + "network.routing_table.node_id" => Ok(Box::new(TypedKeySet::new())), + "network.routing_table.node_id_secret" => Ok(Box::new(TypedSecretSet::new())), "network.routing_table.bootstrap" => Ok(Box::new(Vec::::new())), "network.routing_table.limit_over_attached" => Ok(Box::new(64u32)), "network.routing_table.limit_fully_attached" => Ok(Box::new(32u32)), @@ -329,7 +320,7 @@ pub async fn test_config() { assert_eq!(inner.network.rpc.timeout_ms, 10_000u32); assert_eq!(inner.network.rpc.max_route_hop_count, 4u8); assert_eq!(inner.network.rpc.default_route_hop_count, 1u8); - assert_eq!(inner.network.routing_table.node_ids.len(), 1); + assert_eq!(inner.network.routing_table.node_ids.len(), 0); assert_eq!(inner.network.routing_table.bootstrap, Vec::::new()); assert_eq!(inner.network.routing_table.limit_over_attached, 64u32); assert_eq!(inner.network.routing_table.limit_fully_attached, 32u32); diff --git a/veilid-core/src/veilid_api/types.rs b/veilid-core/src/veilid_api/types.rs index 2f728e2d..18c0e8d0 100644 --- a/veilid-core/src/veilid_api/types.rs +++ b/veilid-core/src/veilid_api/types.rs @@ -1883,7 +1883,7 @@ impl SignedDirectNodeInfo { // Verify the signatures that we can let valid_crypto_kinds = crypto.verify_signatures(node_ids, &node_info_bytes, &typed_signatures)?; - node_ids.remove_all(&valid_crypto_kinds); + xx wrong! should remove only the kinds that are not valid! also fix relayed node_ids.remove_all(&valid_crypto_kinds); if node_ids.len() == 0 { apibail_generic!("no valid node ids in direct node info"); } diff --git a/veilid-core/src/veilid_config.rs b/veilid-core/src/veilid_config.rs index f3045a8a..1bfa1868 100644 --- a/veilid-core/src/veilid_config.rs +++ b/veilid-core/src/veilid_config.rs @@ -622,8 +622,8 @@ impl VeilidConfig { let v = cb(keyname.to_owned())?; $key = match v.downcast() { Ok(v) => *v, - Err(_) => { - apibail_generic!(format!("incorrect type for key {}", keyname)) + Err(e) => { + apibail_generic!(format!("incorrect type for key {}: {:?}", keyname, type_name_of_val(&*e))) } }; }; @@ -632,27 +632,26 @@ impl VeilidConfig { macro_rules! get_config_node_ids { () => { let keys = cb("network.routing_table.node_id".to_owned())?; - let keys: Option = match keys.downcast() { + let keys: TypedKeySet = match keys.downcast() { Ok(v) => *v, - Err(_) => { - apibail_generic!( - "incorrect type for key 'network.routing_table.node_id'".to_owned() - ) + Err(e) => { + apibail_generic!(format!( + "incorrect type for key 'network.routing_table.node_id': {:?}", + type_name_of_val(&*e) + )) } }; - let keys = keys.unwrap_or_default(); let secrets = cb("network.routing_table.node_id_secret".to_owned())?; - let secrets: Option = match secrets.downcast() { + let secrets: TypedSecretSet = match secrets.downcast() { Ok(v) => *v, - Err(_) => { - apibail_generic!( - "incorrect type for key 'network.routing_table.node_id_secret'" - .to_owned() - ) + Err(e) => { + apibail_generic!(format!( + "incorrect type for key 'network.routing_table.node_id_secret': {:?}", + type_name_of_val(&*e) + )) } }; - let secrets = secrets.unwrap_or_default(); for ck in VALID_CRYPTO_KINDS { if let Some(key) = keys.get(ck) { diff --git a/veilid-server/src/settings.rs b/veilid-server/src/settings.rs index 4677e777..3867edbb 100644 --- a/veilid-server/src/settings.rs +++ b/veilid-server/src/settings.rs @@ -1057,11 +1057,23 @@ impl Settings { "network.hole_punch_receipt_time_ms" => { Ok(Box::new(inner.core.network.hole_punch_receipt_time_ms)) } - "network.routing_table.node_id" => { - Ok(Box::new(inner.core.network.routing_table.node_id.clone())) - } + "network.routing_table.node_id" => Ok(Box::new( + inner + .core + .network + .routing_table + .node_id + .clone() + .unwrap_or_default(), + )), "network.routing_table.node_id_secret" => Ok(Box::new( - inner.core.network.routing_table.node_id_secret.clone(), + inner + .core + .network + .routing_table + .node_id_secret + .clone() + .unwrap_or_default(), )), "network.routing_table.bootstrap" => { Ok(Box::new(inner.core.network.routing_table.bootstrap.clone())) diff --git a/veilid-tools/src/tools.rs b/veilid-tools/src/tools.rs index ac3e6be4..a58a1fd6 100644 --- a/veilid-tools/src/tools.rs +++ b/veilid-tools/src/tools.rs @@ -336,3 +336,7 @@ pub fn is_debug_backtrace_enabled() -> bool { } } } + +pub fn type_name_of_val(_val: &T) -> &'static str { + std::any::type_name::() +}