This commit is contained in:
John Smith
2022-11-13 12:48:44 -05:00
parent fd26acec16
commit 4a9d516f32
2 changed files with 56 additions and 16 deletions

View File

@@ -566,7 +566,7 @@ impl VeilidAPI {
}
async fn debug_route_allocate(&self, args: Vec<String>) -> Result<String, VeilidAPIError> {
// [ord|*ord] [rel] [<count>] [in|out]
// [ord|*ord] [rel] [<count>] [in|out] [avoid_node_id]
let netman = self.network_manager()?;
let routing_table = netman.routing_table();
@@ -582,6 +582,7 @@ impl VeilidAPI {
let mut stability = Stability::LowLatency;
let mut hop_count = default_route_hop_count;
let mut directions = DirectionSet::all();
let mut avoid_node_id = None;
while ai < args.len() {
if let Ok(seq) =
@@ -600,6 +601,10 @@ impl VeilidAPI {
get_debug_argument_at(&args, ai, "debug_route", "direction_set", get_direction_set)
{
directions = ds;
} else if let Ok(ani) =
get_debug_argument_at(&args, ai, "debug_route", "avoid_node_id", get_dht_key)
{
avoid_node_id = Some(ani);
} else {
return Ok(format!("Invalid argument specified: {}", args[ai]));
}
@@ -607,13 +612,14 @@ impl VeilidAPI {
}
// Allocate route
let out = match rss.allocate_route(stability, sequencing, hop_count, directions) {
Ok(Some(v)) => format!("{}", v.encode()),
Ok(None) => format!("<unavailable>"),
Err(e) => {
format!("Route allocation failed: {}", e)
}
};
let out =
match rss.allocate_route(stability, sequencing, hop_count, directions, avoid_node_id) {
Ok(Some(v)) => format!("{}", v.encode()),
Ok(None) => format!("<unavailable>"),
Err(e) => {
format!("Route allocation failed: {}", e)
}
};
Ok(out)
}