conn table
This commit is contained in:
parent
5b3d589bf2
commit
671f349578
@ -404,4 +404,12 @@ impl ConnectionManager {
|
|||||||
let _ = sender.send_async(ConnectionManagerEvent::Dead(conn)).await;
|
let _ = sender.send_async(ConnectionManagerEvent::Dead(conn)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn debug_print(&self) -> String {
|
||||||
|
//let inner = self.arc.inner.lock();
|
||||||
|
format!(
|
||||||
|
"Connection Table:\n\n{}",
|
||||||
|
self.arc.connection_table.debug_print_table()
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,15 @@ impl ConnectionTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn index_to_protocol(idx: usize) -> ProtocolType {
|
||||||
|
match idx {
|
||||||
|
0 => ProtocolType::TCP,
|
||||||
|
1 => ProtocolType::WS,
|
||||||
|
2 => ProtocolType::WSS,
|
||||||
|
_ => panic!("not a connection-oriented protocol"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[instrument(level = "trace", skip(self))]
|
#[instrument(level = "trace", skip(self))]
|
||||||
pub async fn join(&self) {
|
pub async fn join(&self) {
|
||||||
let mut unord = {
|
let mut unord = {
|
||||||
@ -331,4 +340,23 @@ impl ConnectionTable {
|
|||||||
let conn = Self::remove_connection_records(&mut *inner, id);
|
let conn = Self::remove_connection_records(&mut *inner, id);
|
||||||
Some(conn)
|
Some(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn debug_print_table(&self) -> String {
|
||||||
|
let mut out = String::new();
|
||||||
|
let inner = self.inner.lock();
|
||||||
|
let cur_ts = get_aligned_timestamp();
|
||||||
|
for t in 0..inner.conn_by_id.len() {
|
||||||
|
out += &format!(
|
||||||
|
" {} Connections: ({}/{})\n",
|
||||||
|
Self::index_to_protocol(t).to_string(),
|
||||||
|
inner.conn_by_id[t].len(),
|
||||||
|
inner.max_connections[t]
|
||||||
|
);
|
||||||
|
|
||||||
|
for (_, conn) in &inner.conn_by_id[t] {
|
||||||
|
out += &format!(" {}\n", conn.debug_print(cur_ts));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -391,6 +391,17 @@ impl NetworkConnection {
|
|||||||
.await;
|
.await;
|
||||||
}.instrument(trace_span!("process_connection")))
|
}.instrument(trace_span!("process_connection")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn debug_print(&self, cur_ts: Timestamp) -> String {
|
||||||
|
format!("{} <- {} | {:x} | est {} sent {} rcvd {}",
|
||||||
|
self.descriptor.remote_address(),
|
||||||
|
self.descriptor.local().map(|x| x.to_string()).unwrap_or("---".to_owned()),
|
||||||
|
self.connection_id.as_u64(),
|
||||||
|
debug_duration(cur_ts.as_u64().saturating_sub(self.established_time.as_u64())),
|
||||||
|
self.stats().last_message_sent_time.map(|ts| debug_duration(cur_ts.as_u64().saturating_sub(ts.as_u64())) ).unwrap_or("---".to_owned()),
|
||||||
|
self.stats().last_message_recv_time.map(|ts| debug_duration(cur_ts.as_u64().saturating_sub(ts.as_u64())) ).unwrap_or("---".to_owned()),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolves ready when the connection loop has terminated
|
// Resolves ready when the connection loop has terminated
|
||||||
|
@ -682,6 +682,7 @@ impl VeilidAPI {
|
|||||||
async fn debug_nodeinfo(&self, _args: String) -> VeilidAPIResult<String> {
|
async fn debug_nodeinfo(&self, _args: String) -> VeilidAPIResult<String> {
|
||||||
// Dump routing table entry
|
// Dump routing table entry
|
||||||
let routing_table = self.network_manager()?.routing_table();
|
let routing_table = self.network_manager()?.routing_table();
|
||||||
|
let connection_manager = self.network_manager()?.connection_manager();
|
||||||
let nodeinfo = routing_table.debug_info_nodeinfo();
|
let nodeinfo = routing_table.debug_info_nodeinfo();
|
||||||
|
|
||||||
// Dump core state
|
// Dump core state
|
||||||
@ -702,7 +703,11 @@ impl VeilidAPI {
|
|||||||
format_opt_bps(Some(peer.peer_stats.transfer.up.average)),
|
format_opt_bps(Some(peer.peer_stats.transfer.up.average)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Ok(format!("{}\n\n{}\n\n", nodeinfo, peertable))
|
|
||||||
|
// Dump connection table
|
||||||
|
let connman = connection_manager.debug_print().await;
|
||||||
|
|
||||||
|
Ok(format!("{}\n\n{}\n\n{}\n\n", nodeinfo, peertable, connman))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn debug_config(&self, args: String) -> VeilidAPIResult<String> {
|
async fn debug_config(&self, args: String) -> VeilidAPIResult<String> {
|
||||||
|
Loading…
Reference in New Issue
Block a user