diff --git a/protocols/relay/CHANGELOG.md b/protocols/relay/CHANGELOG.md index 6b10255b..2f593020 100644 --- a/protocols/relay/CHANGELOG.md +++ b/protocols/relay/CHANGELOG.md @@ -4,6 +4,10 @@ - Update to `libp2p-swarm` `v0.37.0`. +- 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/src/v2/relay.rs b/protocols/relay/src/v2/relay.rs index 8d8bb75c..ed5fe6ca 100644 --- a/protocols/relay/src/v2/relay.rs +++ b/protocols/relay/src/v2/relay.rs @@ -756,9 +756,13 @@ impl Action { inbound_reservation_req, addrs: poll_parameters .external_addresses() - .map(|a| { - a.addr - .with(Protocol::P2p((*poll_parameters.local_peer_id()).into())) + .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(), }),