Skip to content

Commit b3f3b59

Browse files
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
1 parent 225b01f commit b3f3b59

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

protocols/relay/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.9.2 - unreleased
2+
3+
- Do not duplicate the p2p/xxx component with the relay PeerId when a client requests a reservation. See [PR 2701].
4+
5+
[PR 2701]: https://github.com/libp2p/rust-libp2p/pull/2701/
6+
17
# 0.9.1
28

39
- Respond to at most one incoming reservation request. Deny <= 8 incoming

protocols/relay/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-relay"
33
edition = "2021"
44
rust-version = "1.56.1"
55
description = "Communications relaying for libp2p"
6-
version = "0.9.1"
6+
version = "0.9.2"
77
authors = ["Parity Technologies <[email protected]>", "Max Inden <[email protected]>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"

protocols/relay/src/v2/relay.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -756,13 +756,13 @@ impl Action {
756756
inbound_reservation_req,
757757
addrs: poll_parameters
758758
.external_addresses()
759-
.map(|a| {
760-
let p2p_proto =
761-
Protocol::P2p(*poll_parameters.local_peer_id().as_ref());
762-
match a.addr.iter().last() {
763-
Some(p) if p == p2p_proto => a.addr,
764-
_ => a.addr.with(p2p_proto),
765-
}
759+
.map(|a| a.addr)
760+
// Add local peer ID in case it isn't present yet.
761+
.filter_map(|a| match a.iter().last()? {
762+
Protocol::P2p(_) => Some(a),
763+
_ => Some(
764+
a.with(Protocol::P2p(*poll_parameters.local_peer_id().as_ref())),
765+
),
766766
})
767767
.collect(),
768768
}),

0 commit comments

Comments
 (0)