Skip to content

Commit

Permalink
fix(relay): malformed reported relayed addr when relay peer is dialer
Browse files Browse the repository at this point in the history
  • Loading branch information
stormshield-frb committed Aug 29, 2024
1 parent cefd22b commit 782eb8e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ libp2p-ping = { version = "0.45.0", path = "protocols/ping" }
libp2p-plaintext = { version = "0.42.0", path = "transports/plaintext" }
libp2p-pnet = { version = "0.25.0", path = "transports/pnet" }
libp2p-quic = { version = "0.11.1", path = "transports/quic" }
libp2p-relay = { version = "0.18.0", path = "protocols/relay" }
libp2p-relay = { version = "0.18.1", path = "protocols/relay" }
libp2p-rendezvous = { version = "0.15.0", path = "protocols/rendezvous" }
libp2p-request-response = { version = "0.27.0", path = "protocols/request-response" }
libp2p-server = { version = "0.12.7", path = "misc/server" }
Expand Down
5 changes: 5 additions & 0 deletions protocols/relay/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.18.1

- Fix malformed reported relayed address when relay peer was dialer.
See [PR 5576](https://github.com/libp2p/rust-libp2p/pull/5576).

## 0.18.0

<!-- Update to libp2p-swarm v0.45.0 -->
Expand Down
2 changes: 1 addition & 1 deletion protocols/relay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-relay"
edition = "2021"
rust-version = { workspace = true }
description = "Communications relaying for libp2p"
version = "0.18.0"
version = "0.18.1"
authors = ["Parity Technologies <[email protected]>", "Max Inden <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
10 changes: 9 additions & 1 deletion protocols/relay/src/priv_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,15 @@ impl NetworkBehaviour for Behaviour {
if local_addr.is_relayed() {
return Ok(Either::Right(dummy::ConnectionHandler));
}
let mut handler = Handler::new(self.local_peer_id, peer, remote_addr.clone());

let mut handler = match remote_addr.clone().with_p2p(peer) {
Ok(remote_addr) => Handler::new(self.local_peer_id, peer, remote_addr),
Err(remote_addr) => {
return Err(ConnectionDenied::new(format!(
"addr {remote_addr} contains a PeerId not matching {peer}"
)))
}
};

if let Some(event) = self.pending_handler_commands.remove(&connection_id) {
handler.on_behaviour_event(event)
Expand Down

0 comments on commit 782eb8e

Please sign in to comment.