mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-10-01 01:26:08 -04:00
add entries debug command filter by capability
This commit is contained in:
parent
cdedf37ade
commit
0589e6dc31
@ -104,7 +104,11 @@ impl RoutingTable {
|
||||
out
|
||||
}
|
||||
|
||||
pub(crate) fn debug_info_entries(&self, min_state: BucketEntryState) -> String {
|
||||
pub(crate) fn debug_info_entries(
|
||||
&self,
|
||||
min_state: BucketEntryState,
|
||||
capabilities: Vec<FourCC>,
|
||||
) -> String {
|
||||
let inner = self.inner.read();
|
||||
let inner = &*inner;
|
||||
let cur_ts = get_aligned_timestamp();
|
||||
@ -117,25 +121,30 @@ impl RoutingTable {
|
||||
let routing_domain = ec.0 .0;
|
||||
let crypto_kind = ec.0 .1;
|
||||
let count = ec.1;
|
||||
out += &format!(" {:?}:{}: {}\n", routing_domain, crypto_kind, count);
|
||||
out += &format!("{:?}: {}: {}\n", routing_domain, crypto_kind, count);
|
||||
}
|
||||
for ck in &VALID_CRYPTO_KINDS {
|
||||
let mut filtered_total = 0;
|
||||
let mut b = 0;
|
||||
let blen = inner.buckets[ck].len();
|
||||
while b < blen {
|
||||
let filtered_entries: Vec<(&PublicKey, &Arc<BucketEntry>)> = inner.buckets[ck][b]
|
||||
.entries()
|
||||
.filter(|e| {
|
||||
let cap_match = e.1.with(inner, |_rti, e| {
|
||||
e.has_capabilities(RoutingDomain::PublicInternet, &capabilities)
|
||||
});
|
||||
let state = e.1.with(inner, |_rti, e| e.state(cur_ts));
|
||||
state >= min_state
|
||||
state >= min_state && cap_match
|
||||
})
|
||||
.collect();
|
||||
filtered_total += filtered_entries.len();
|
||||
if !filtered_entries.is_empty() {
|
||||
out += &format!("{} Bucket #{}:\n", ck, b);
|
||||
for e in filtered_entries {
|
||||
let state = e.1.with(inner, |_rti, e| e.state(cur_ts));
|
||||
out += &format!(
|
||||
" {} [{}] {}\n",
|
||||
" {} [{}] {} [{}]\n",
|
||||
e.0.encode(),
|
||||
match state {
|
||||
BucketEntryState::Reliable => "R",
|
||||
@ -153,12 +162,24 @@ impl RoutingTable {
|
||||
)
|
||||
})
|
||||
.unwrap_or_else(|| "???.??ms".to_string())
|
||||
}),
|
||||
e.1.with(inner, |_rti, e| {
|
||||
if let Some(ni) = e.node_info(RoutingDomain::PublicInternet) {
|
||||
ni.capabilities()
|
||||
.iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join(",")
|
||||
} else {
|
||||
"???".to_owned()
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
b += 1;
|
||||
}
|
||||
out += &format!("{} Filtered Total: {}\n", ck, filtered_total);
|
||||
}
|
||||
|
||||
out
|
||||
|
@ -676,17 +676,24 @@ impl VeilidAPI {
|
||||
let args: Vec<String> = args.split_whitespace().map(|s| s.to_owned()).collect();
|
||||
|
||||
let mut min_state = BucketEntryState::Unreliable;
|
||||
let mut capabilities = vec![];
|
||||
for arg in args {
|
||||
if let Some(ms) = get_bucket_entry_state(&arg) {
|
||||
min_state = ms;
|
||||
} else {
|
||||
apibail_invalid_argument!("debug_entries", "unknown", arg);
|
||||
for cap in arg.split(',') {
|
||||
if let Ok(capfcc) = FourCC::from_str(cap) {
|
||||
capabilities.push(capfcc);
|
||||
} else {
|
||||
apibail_invalid_argument!("debug_entries", "unknown", arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dump routing table entries
|
||||
let routing_table = self.network_manager()?.routing_table();
|
||||
Ok(routing_table.debug_info_entries(min_state))
|
||||
Ok(routing_table.debug_info_entries(min_state, capabilities))
|
||||
}
|
||||
|
||||
async fn debug_entry(&self, args: String) -> VeilidAPIResult<String> {
|
||||
@ -1917,7 +1924,7 @@ impl VeilidAPI {
|
||||
Ok(r#"buckets [dead|reliable]
|
||||
dialinfo
|
||||
peerinfo [routingdomain]
|
||||
entries [dead|reliable]
|
||||
entries [dead|reliable] [<capabilities>]
|
||||
entry <node>
|
||||
nodeinfo
|
||||
config [insecure] [configkey [new value]]
|
||||
@ -1959,6 +1966,7 @@ record list <local|remote>
|
||||
--------------------------------------------------------------------
|
||||
<key> is: VLD0:GsgXCRPrzSK6oBNgxhNpm-rTYFd02R0ySx6j9vbQBG4
|
||||
* also <node>, <relay>, <target>, <route>
|
||||
<capabilities> is: a list of FourCC codes: ROUT,SGNL,RLAY,DIAL,DHTV,DHTW,APPM etc.
|
||||
<configkey> is: dot path like network.protocol.udp.enabled
|
||||
<destination> is:
|
||||
* direct: <node>[+<safety>][<modifiers>]
|
||||
|
Loading…
Reference in New Issue
Block a user