mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-11-30 01:44:58 +03:00
bugfixes #1
This commit is contained in:
parent
6c1a672cee
commit
b0b7ba8650
@ -217,10 +217,18 @@ pub async fn maintain_connection(
|
||||
// with the matching peer handler "sender".
|
||||
//
|
||||
if let Some(peer) = peers.read().await.get(to) {
|
||||
let _ = peer.sender.send((
|
||||
let id = *id;
|
||||
let to = to.clone();
|
||||
match peer.sender.send((
|
||||
PeerMessage::Net(net_message),
|
||||
Some(forwarding_ack_tx.clone()),
|
||||
));
|
||||
)) {
|
||||
Ok(_) => {},
|
||||
Err(_) => {
|
||||
peers.write().await.remove(&to);
|
||||
message_tx.send((NetworkMessage::Nack(id), None)).unwrap();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if we don't have the peer, throw a nack.
|
||||
// println!("net: nacking message with id {id}\r");
|
||||
@ -467,10 +475,10 @@ async fn peer_handler(
|
||||
break;
|
||||
}
|
||||
println!("net: failed to deserialize message from {}\r", who);
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
println!("net: failed to decrypt message from {}, could be spoofer\r", who);
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
} => {
|
||||
// println!("net: lost peer {who}\r");
|
||||
|
@ -98,8 +98,16 @@ pub async fn networking(
|
||||
//
|
||||
if let Some(peer) = peers_read.get(target) {
|
||||
// println!("net: direct send to known peer\r");
|
||||
let _ = peer.sender.send((PeerMessage::Raw(km.clone()), None));
|
||||
continue;
|
||||
match peer.sender.send((PeerMessage::Raw(km.clone()), None)) {
|
||||
Ok(_) => continue,
|
||||
Err(_) => {
|
||||
// println!("net: failed to send to known peer\r");
|
||||
drop(peers_read);
|
||||
peers.write().await.remove(target);
|
||||
error_offline(km, &network_error_tx).await;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
drop(peers_read);
|
||||
//
|
||||
@ -585,14 +593,14 @@ async fn connect_to_routers(
|
||||
let response_shake = match timeout(TIMEOUT, handshake_rx.recv()).await {
|
||||
Ok(Some(Ok(NetworkMessage::HandshakeAck(shake)))) => shake,
|
||||
_ => {
|
||||
println!("net: failed handshake with {router_name}\r");
|
||||
// println!("net: failed handshake with {router_name}\r");
|
||||
conn_handle.abort();
|
||||
let _ = routers_to_try_tx.send(router_name);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let Ok(their_ephemeral_pk) = validate_handshake(&response_shake, &router_id) else {
|
||||
println!("net: failed handshake with {router_name}\r");
|
||||
// println!("net: failed handshake with {router_name}\r");
|
||||
conn_handle.abort();
|
||||
let _ = routers_to_try_tx.send(router_name);
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user