Skip to content

Commit

Permalink
feat(request-response): Add connection id to behaviour events
Browse files Browse the repository at this point in the history
Closes #5716.

Added connection id to the events emitted by a request-response Behaviour and adapted the code accordingly.

Pull-Request: #5719.
  • Loading branch information
BastienFaivre authored Dec 10, 2024
1 parent 78e6f08 commit 276ce84
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 31 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ rust-version = "1.75.0"
[workspace.dependencies]
libp2p = { version = "0.54.2", path = "libp2p" }
libp2p-allow-block-list = { version = "0.4.2", path = "misc/allow-block-list" }
libp2p-autonat = { version = "0.13.1", path = "protocols/autonat" }
libp2p-autonat = { version = "0.13.2", path = "protocols/autonat" }
libp2p-connection-limits = { version = "0.4.1", path = "misc/connection-limits" }
libp2p-core = { version = "0.42.1", path = "core" }
libp2p-dcutr = { version = "0.12.1", path = "protocols/dcutr" }
Expand All @@ -95,8 +95,8 @@ libp2p-plaintext = { version = "0.42.0", path = "transports/plaintext" }
libp2p-pnet = { version = "0.25.0", path = "transports/pnet" }
libp2p-quic = { version = "0.11.2", path = "transports/quic" }
libp2p-relay = { version = "0.18.1", path = "protocols/relay" }
libp2p-rendezvous = { version = "0.15.0", path = "protocols/rendezvous" }
libp2p-request-response = { version = "0.27.1", path = "protocols/request-response" }
libp2p-rendezvous = { version = "0.15.1", path = "protocols/rendezvous" }
libp2p-request-response = { version = "0.28.0", path = "protocols/request-response" }
libp2p-server = { version = "0.12.8", path = "misc/server" }
libp2p-stream = { version = "0.2.0-alpha.1", path = "protocols/stream" }
libp2p-swarm = { version = "0.45.2", path = "swarm" }
Expand Down
4 changes: 4 additions & 0 deletions protocols/autonat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.13.2

- Update to `libp2p-request-response` `v0.28.0`.

## 0.13.1

- Verify that an incoming AutoNAT dial comes from a connected peer. See [PR 5597](https://github.com/libp2p/rust-libp2p/pull/5597).
Expand Down
2 changes: 1 addition & 1 deletion protocols/autonat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-autonat"
edition = "2021"
rust-version = { workspace = true }
description = "NAT and firewall detection for libp2p"
version = "0.13.1"
version = "0.13.2"
authors = [
"David Craven <david@craven.ch>",
"Elena Frank <elena.frank@protonmail.com>",
Expand Down
2 changes: 2 additions & 0 deletions protocols/autonat/src/v1/behaviour/as_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl HandleInnerEvent for AsClient<'_> {
request_id,
response,
},
..
} => {
tracing::debug!(?response, "Outbound dial-back request returned response");

Expand Down Expand Up @@ -154,6 +155,7 @@ impl HandleInnerEvent for AsClient<'_> {
peer,
error,
request_id,
..
} => {
tracing::debug!(
%peer,
Expand Down
2 changes: 2 additions & 0 deletions protocols/autonat/src/v1/behaviour/as_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ impl HandleInnerEvent for AsServer<'_> {
request,
channel,
},
..
} => {
let probe_id = self.probe_id.next();
if !self.connected.contains_key(&peer) {
Expand Down Expand Up @@ -183,6 +184,7 @@ impl HandleInnerEvent for AsServer<'_> {
peer,
error,
request_id,
..
} => {
tracing::debug!(
%peer,
Expand Down
4 changes: 4 additions & 0 deletions protocols/rendezvous/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.15.1

- Update to `libp2p-request-response` `v0.28.0`.

## 0.15.0

<!-- Update to libp2p-swarm v0.45.0 -->
Expand Down
2 changes: 1 addition & 1 deletion protocols/rendezvous/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-rendezvous"
edition = "2021"
rust-version = { workspace = true }
description = "Rendezvous protocol for libp2p"
version = "0.15.0"
version = "0.15.1"
authors = ["The COMIT guys <hello@comit.network>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
3 changes: 3 additions & 0 deletions protocols/rendezvous/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ impl NetworkBehaviour for Behaviour {
libp2p_request_response::Message::Request {
request, channel, ..
},
..
}) => {
if let Some((event, response)) =
handle_request(peer_id, request, &mut self.registrations)
Expand All @@ -202,6 +203,7 @@ impl NetworkBehaviour for Behaviour {
peer,
request_id,
error,
..
}) => {
tracing::warn!(
%peer,
Expand All @@ -217,6 +219,7 @@ impl NetworkBehaviour for Behaviour {
| ToSwarm::GenerateEvent(libp2p_request_response::Event::Message {
peer: _,
message: libp2p_request_response::Message::Response { .. },
..
})
| ToSwarm::GenerateEvent(libp2p_request_response::Event::OutboundFailure {
..
Expand Down
5 changes: 5 additions & 0 deletions protocols/request-response/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.28.0

- Add connection id to the events emitted by a request-response `Behaviour`.
See [PR 5719](https://github.com/libp2p/rust-libp2p/pull/5719).

## 0.27.1

- Deprecate `void` crate.
Expand Down
2 changes: 1 addition & 1 deletion protocols/request-response/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-request-response"
edition = "2021"
rust-version = { workspace = true }
description = "Generic Request/Response Protocols"
version = "0.27.1"
version = "0.28.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
Loading

0 comments on commit 276ce84

Please sign in to comment.