mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-10-01 01:26:08 -04:00
fix debug
This commit is contained in:
parent
f298650ffa
commit
f8060715ce
@ -30,7 +30,7 @@ fn get_string(text: &str) -> Option<String> {
|
|||||||
Some(text.to_owned())
|
Some(text.to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_route_id(rss: RouteSpecStore) -> impl Fn(&str) -> Option<RouteId> {
|
fn get_route_id(rss: RouteSpecStore, allow_remote: bool) -> impl Fn(&str) -> Option<RouteId> {
|
||||||
return move |text: &str| {
|
return move |text: &str| {
|
||||||
if text.is_empty() {
|
if text.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
@ -41,6 +41,12 @@ fn get_route_id(rss: RouteSpecStore) -> impl Fn(&str) -> Option<RouteId> {
|
|||||||
if routes.contains(&key) {
|
if routes.contains(&key) {
|
||||||
return Some(key);
|
return Some(key);
|
||||||
}
|
}
|
||||||
|
if allow_remote {
|
||||||
|
let rroutes = rss.list_remote_routes(|k, _| Some(*k));
|
||||||
|
if rroutes.contains(&key) {
|
||||||
|
return Some(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let routes = rss.list_allocated_routes(|k, _| Some(*k));
|
let routes = rss.list_allocated_routes(|k, _| Some(*k));
|
||||||
@ -50,6 +56,15 @@ fn get_route_id(rss: RouteSpecStore) -> impl Fn(&str) -> Option<RouteId> {
|
|||||||
return Some(r);
|
return Some(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if allow_remote {
|
||||||
|
let routes = rss.list_remote_routes(|k, _| Some(*k));
|
||||||
|
for r in routes {
|
||||||
|
let rkey = r.encode();
|
||||||
|
if rkey.starts_with(text) {
|
||||||
|
return Some(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
@ -74,7 +89,7 @@ fn get_safety_selection(text: &str, routing_table: RoutingTable) -> Option<Safet
|
|||||||
let mut sequencing = Sequencing::default();
|
let mut sequencing = Sequencing::default();
|
||||||
for x in text.split(",") {
|
for x in text.split(",") {
|
||||||
let x = x.trim();
|
let x = x.trim();
|
||||||
if let Some(pr) = get_route_id(rss.clone())(x) {
|
if let Some(pr) = get_route_id(rss.clone(), false)(x) {
|
||||||
preferred_route = Some(pr)
|
preferred_route = Some(pr)
|
||||||
}
|
}
|
||||||
if let Some(n) = get_number(x) {
|
if let Some(n) = get_number(x) {
|
||||||
@ -649,12 +664,22 @@ impl VeilidAPI {
|
|||||||
1,
|
1,
|
||||||
"debug_route",
|
"debug_route",
|
||||||
"route_id",
|
"route_id",
|
||||||
get_route_id(rss.clone()),
|
get_route_id(rss.clone(), true),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Release route
|
// Release route
|
||||||
let out = match rss.release_route(route_id) {
|
let out = match rss.release_route(route_id) {
|
||||||
true => "Released".to_owned(),
|
true => {
|
||||||
|
// release imported
|
||||||
|
let mut dc = DEBUG_CACHE.lock();
|
||||||
|
for (n, ir) in dc.imported_routes.iter().enumerate() {
|
||||||
|
if *ir == route_id {
|
||||||
|
dc.imported_routes.remove(n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"Released".to_owned()
|
||||||
|
}
|
||||||
false => "Route does not exist".to_owned(),
|
false => "Route does not exist".to_owned(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -671,7 +696,7 @@ impl VeilidAPI {
|
|||||||
1,
|
1,
|
||||||
"debug_route",
|
"debug_route",
|
||||||
"route_id",
|
"route_id",
|
||||||
get_route_id(rss.clone()),
|
get_route_id(rss.clone(), false),
|
||||||
)?;
|
)?;
|
||||||
let full = {
|
let full = {
|
||||||
if args.len() > 2 {
|
if args.len() > 2 {
|
||||||
@ -723,7 +748,7 @@ impl VeilidAPI {
|
|||||||
1,
|
1,
|
||||||
"debug_route",
|
"debug_route",
|
||||||
"route_id",
|
"route_id",
|
||||||
get_route_id(rss.clone()),
|
get_route_id(rss.clone(), false),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Unpublish route
|
// Unpublish route
|
||||||
@ -745,7 +770,7 @@ impl VeilidAPI {
|
|||||||
1,
|
1,
|
||||||
"debug_route",
|
"debug_route",
|
||||||
"route_id",
|
"route_id",
|
||||||
get_route_id(rss.clone()),
|
get_route_id(rss.clone(), true),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
match rss.debug_route(&route_id) {
|
match rss.debug_route(&route_id) {
|
||||||
@ -807,7 +832,7 @@ impl VeilidAPI {
|
|||||||
1,
|
1,
|
||||||
"debug_route",
|
"debug_route",
|
||||||
"route_id",
|
"route_id",
|
||||||
get_route_id(rss.clone()),
|
get_route_id(rss.clone(), true),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let success = rss
|
let success = rss
|
||||||
|
Loading…
Reference in New Issue
Block a user