This commit is contained in:
John Smith 2023-03-01 20:12:30 -05:00
parent 562f9bb7f7
commit dfd1af0c6b
6 changed files with 39 additions and 32 deletions

1
.vscode/launch.json vendored
View File

@ -75,6 +75,7 @@
"args": [
"test",
"--no-run",
"--features=rt-tokio",
"--manifest-path",
"veilid-core/Cargo.toml"
],

View File

@ -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::<CryptoKind, VeilidConfigNodeId>::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::<String>::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::<String>::new());
assert_eq!(inner.network.routing_table.limit_over_attached, 64u32);
assert_eq!(inner.network.routing_table.limit_fully_attached, 32u32);

View File

@ -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");
}

View File

@ -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<TypedKeySet> = 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<TypedSecretSet> = 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) {

View File

@ -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()))

View File

@ -336,3 +336,7 @@ pub fn is_debug_backtrace_enabled() -> bool {
}
}
}
pub fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str {
std::any::type_name::<T>()
}