From 225b01f4cc061ecb419f56d170c978c52ee88cc3 Mon Sep 17 00:00:00 2001 From: Philippe Jalaber Date: Fri, 10 Jun 2022 10:54:04 +0200 Subject: [PATCH 1/2] Multiaddr duplicated p2p protocol in relay reservation (#2696) --- protocols/relay/src/v2/relay.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/protocols/relay/src/v2/relay.rs b/protocols/relay/src/v2/relay.rs index 8d8bb75caa9..30ceb2bda6f 100644 --- a/protocols/relay/src/v2/relay.rs +++ b/protocols/relay/src/v2/relay.rs @@ -757,8 +757,12 @@ impl Action { addrs: poll_parameters .external_addresses() .map(|a| { - a.addr - .with(Protocol::P2p((*poll_parameters.local_peer_id()).into())) + let p2p_proto = + Protocol::P2p(*poll_parameters.local_peer_id().as_ref()); + match a.addr.iter().last() { + Some(p) if p == p2p_proto => a.addr, + _ => a.addr.with(p2p_proto), + } }) .collect(), }), From b3f3b59bfa687550e09398411b1318dea98d8280 Mon Sep 17 00:00:00 2001 From: Philippe Jalaber Date: Wed, 15 Jun 2022 09:54:40 +0200 Subject: [PATCH 2/2] Multiaddr duplicated p2p protocol in relay reservation (#2696) - Minor fixes after review - Bump libp2p-relay Cargo.toml version to 0.9.2 - Add entry in Changelog for upcoming 0.9.2 version --- protocols/relay/CHANGELOG.md | 6 ++++++ protocols/relay/Cargo.toml | 2 +- protocols/relay/src/v2/relay.rs | 14 +++++++------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/protocols/relay/CHANGELOG.md b/protocols/relay/CHANGELOG.md index 46d3b2ffcee..8df4de38fac 100644 --- a/protocols/relay/CHANGELOG.md +++ b/protocols/relay/CHANGELOG.md @@ -1,3 +1,9 @@ +# 0.9.2 - unreleased + +- Do not duplicate the p2p/xxx component with the relay PeerId when a client requests a reservation. See [PR 2701]. + +[PR 2701]: https://github.com/libp2p/rust-libp2p/pull/2701/ + # 0.9.1 - Respond to at most one incoming reservation request. Deny <= 8 incoming diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index 7fe66e547d1..e5470672fca 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-relay" edition = "2021" rust-version = "1.56.1" description = "Communications relaying for libp2p" -version = "0.9.1" +version = "0.9.2" authors = ["Parity Technologies ", "Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/relay/src/v2/relay.rs b/protocols/relay/src/v2/relay.rs index 30ceb2bda6f..ed5fe6ca326 100644 --- a/protocols/relay/src/v2/relay.rs +++ b/protocols/relay/src/v2/relay.rs @@ -756,13 +756,13 @@ impl Action { inbound_reservation_req, addrs: poll_parameters .external_addresses() - .map(|a| { - let p2p_proto = - Protocol::P2p(*poll_parameters.local_peer_id().as_ref()); - match a.addr.iter().last() { - Some(p) if p == p2p_proto => a.addr, - _ => a.addr.with(p2p_proto), - } + .map(|a| a.addr) + // Add local peer ID in case it isn't present yet. + .filter_map(|a| match a.iter().last()? { + Protocol::P2p(_) => Some(a), + _ => Some( + a.with(Protocol::P2p(*poll_parameters.local_peer_id().as_ref())), + ), }) .collect(), }),