From a56f3fa7e711ec3f210cb1b70df96aae94bedc0d Mon Sep 17 00:00:00 2001 From: Lee Smet Date: Wed, 22 Nov 2023 16:54:56 +0100 Subject: [PATCH] Remove exchanged overlay IP of peers Signed-off-by: Lee Smet --- CHANGELOG.md | 6 ++++++ src/peer.rs | 9 --------- src/peer_manager.rs | 6 ++---- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 912aaaa..86ebca4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ignore retraction updates if the route table has an existing but retracted route already. This fixes an issue where retracted routes would not be flushed from the routing table. +### Removed + +- All uses of the exchanged overlay IP in the peer handshake are fully + removed. Handshake is still performed to stay backwards compatible + until the next breaking release. + ## [0.1.2] - 2023-11-15 ### Changed diff --git a/src/peer.rs b/src/peer.rs index d53cd34..d72d252 100644 --- a/src/peer.rs +++ b/src/peer.rs @@ -51,7 +51,6 @@ impl Peer { router_data_tx: mpsc::Sender, router_control_tx: mpsc::UnboundedSender<(ControlPacket, Peer)>, stream: TcpStream, - overlay_ip: IpAddr, dead_peer_sink: mpsc::Sender, ) -> Result> { // Data channel for peer @@ -67,7 +66,6 @@ impl Peer { to_peer_data, to_peer_control, stream_ip, - overlay_ip, }), }; @@ -174,11 +172,6 @@ impl Peer { self.inner.state.write().unwrap().time_last_received_hello = time } - /// Get overlay IP for this peer - pub fn overlay_ip(&self) -> IpAddr { - self.inner.overlay_ip - } - /// For sending data packets towards a peer instance on this node. /// It's send over the to_peer_data channel and read from the corresponding receiver. /// The receiver sends the packet over the TCP stream towards the destined peer instance on another node @@ -247,8 +240,6 @@ struct PeerInner { to_peer_control: mpsc::UnboundedSender, /// Used to identify peer based on its connection params stream_ip: IpAddr, - // TODO: not needed - overlay_ip: IpAddr, } #[derive(Debug)] diff --git a/src/peer_manager.rs b/src/peer_manager.rs index 3421f29..a2c8980 100644 --- a/src/peer_manager.rs +++ b/src/peer_manager.rs @@ -48,7 +48,7 @@ impl PeerManager { info!("Failed to read hanshake from peer: {e}"); continue; } - let received_overlay_ip = match buffer[0] { + let _ = match buffer[0] { 0 => IpAddr::from( <&[u8] as TryInto<[u8; 4]>>::try_into(&buffer[1..5]).unwrap(), ), @@ -77,7 +77,6 @@ impl PeerManager { self.router.router_data_tx(), self.router.router_control_tx(), peer_stream, - received_overlay_ip, self.router.dead_peer_sink().clone(), ) { info!("Connected to new peer {}", new_peer.underlay_ip()); @@ -154,7 +153,7 @@ impl PeerManager { stream.write_all(&buf).await?; // Step 2 stream.read_exact(&mut buf).await?; - let received_overlay_ip = match buf[0] { + let _ = match buf[0] { 0 => IpAddr::from(<&[u8] as TryInto<[u8; 4]>>::try_into(&buf[1..5]).unwrap()), 1 => IpAddr::from(<&[u8] as TryInto<[u8; 16]>>::try_into(&buf[1..]).unwrap()), _ => { @@ -174,7 +173,6 @@ impl PeerManager { router_data_tx, router_control_tx, stream, - received_overlay_ip, dead_peer_sink, ) }