Kill peer connection if router appears to be gone

If the router is gone (or the receiver of the packet forward channels,
at least), peers got stuck repeatedly trying to forward packets to said
router.

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
Lee Smet committed 2024-05-29 09:56:04 +02:00
1 parent 1764d7dd30
commit f41811b669
2 files changed
+8

No files matched your search

+2
View File
@@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Only do the periodic route announcement every 5 minutes instead of every minute.
- Mycelium binary is no longer part of the workspace, and no longer contains private
network functionality.
- If a packet received from a peer can't be forwarded to the router, terminate the
connection to the peer.
### Fixed
+6
View File
@@ -98,13 +98,19 @@ impl Peer {
Some(Ok(packet)) => {
match packet {
Packet::DataPacket(packet) => {
// An error here means the receiver is dropped/closed,
// this is not recoverable.
if let Err(error) = router_data_tx.send(packet).await{
error!("Error sending to to_routing_data: {}", error);
break
}
}
Packet::ControlPacket(packet) => {
if let Err(error) = router_control_tx.send((packet, peer.clone())) {
// An error here means the receiver is dropped/closed,
// this is not recoverable.
error!("Error sending to to_routing_control: {}", error);
break
}
}