net: bugfix for router-init

This commit is contained in:
dr-frmr 2023-11-06 11:14:50 -05:00
parent 05cdf2188a
commit 545018f8f5
No known key found for this signature in database
2 changed files with 27 additions and 12 deletions

12
Cargo.lock generated
View File

@ -189,6 +189,17 @@ dependencies = [
"term",
]
[[package]]
name = "async-recursion"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.32",
]
[[package]]
name = "async-trait"
version = "0.1.73"
@ -5031,6 +5042,7 @@ version = "0.1.0"
dependencies = [
"aes-gcm 0.10.2",
"anyhow",
"async-recursion",
"async-trait",
"base64 0.13.1",
"bincode",

View File

@ -399,20 +399,16 @@ async fn direct_networking(
// forwarding connections joinset
match conn {
Connection::Peer(peer_conn) => {
let (peer_tx, peer_rx) = unbounded_channel::<KernelMessage>();
let peer = Arc::new(RwLock::new(Peer {
identity: peer_id,
save_new_peer(
&peer_id,
routing_for,
sender: peer_tx,
}));
peers.insert(peer.read().await.identity.name.clone(), peer.clone());
peer_connections.spawn(maintain_connection(
peer,
&mut peers,
&mut peer_connections,
peer_conn,
peer_rx,
kernel_message_tx.clone(),
print_tx.clone(),
));
None,
&kernel_message_tx,
&print_tx
).await?;
}
Connection::Passthrough(passthrough_conn) => {
forwarding_connections.spawn(maintain_passthrough(
@ -891,6 +887,13 @@ async fn handle_local_message(
"we have connections with peers: {:#?}\r\n",
peers.keys()
));
printout.push_str(&format!(
"we are routing for: {:#?}\r\n",
peers
.iter()
.filter(|(_, peer)| peer.read().await.routing_for)
.map(|(id, _)| id)
));
printout.push_str(&format!("we have {} entries in the PKI\r\n", pki.len()));
printout.push_str(&format!(
"we have {} open peer connections\r\n",