From 6c4a02e8b97433d7b1dec88fd3e6a2a8b2723800 Mon Sep 17 00:00:00 2001 From: Prabhat1308 Date: Wed, 3 Jul 2024 01:52:26 +0530 Subject: [PATCH 1/5] add resource limits to CircuitReq Signed-off-by: Prabhat1308 --- protocols/relay/src/protocol/inbound_hop.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/protocols/relay/src/protocol/inbound_hop.rs b/protocols/relay/src/protocol/inbound_hop.rs index 57b5d9ad039..858bb487012 100644 --- a/protocols/relay/src/protocol/inbound_hop.rs +++ b/protocols/relay/src/protocol/inbound_hop.rs @@ -115,6 +115,8 @@ impl ReservationReq { pub struct CircuitReq { dst: PeerId, substream: Framed>, + max_circuit_duration: Duration, + max_circuit_bytes: u64, } impl CircuitReq { @@ -127,7 +129,15 @@ impl CircuitReq { type_pb: proto::HopMessageType::STATUS, peer: None, reservation: None, - limit: None, + limit: Some(proto::Limit { + duration: Some( + self.max_circuit_duration + .as_secs() + .try_into() + .expect("`max_circuit_duration` not to exceed `u32::MAX`."), + ), + data: Some(self.max_circuit_bytes), + }), status: Some(proto::Status::OK), }; From bc55ea69976de986ee5059fff610acfbdf67f6a6 Mon Sep 17 00:00:00 2001 From: Prabhat1308 Date: Wed, 3 Jul 2024 01:57:51 +0530 Subject: [PATCH 2/5] fixes Signed-off-by: Prabhat1308 --- protocols/relay/src/protocol/inbound_hop.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/relay/src/protocol/inbound_hop.rs b/protocols/relay/src/protocol/inbound_hop.rs index 858bb487012..09534c4c4a7 100644 --- a/protocols/relay/src/protocol/inbound_hop.rs +++ b/protocols/relay/src/protocol/inbound_hop.rs @@ -214,7 +214,7 @@ pub(crate) async fn handle_inbound_request( let dst = peer_id_res.map_err(|_| Error::ParsePeerId)?; - Either::Right(CircuitReq { dst, substream }) + Either::Right(CircuitReq { dst, substream , max_circuit_duration, max_circuit_bytes}) } Type::STATUS => return Err(Error::UnexpectedTypeStatus), }; From 6f9c1b847da954dae850d0dec10c7d288fdb95c5 Mon Sep 17 00:00:00 2001 From: Prabhat1308 Date: Fri, 12 Jul 2024 00:20:46 +0530 Subject: [PATCH 3/5] add change log entry Signed-off-by: Prabhat1308 --- protocols/relay/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/protocols/relay/CHANGELOG.md b/protocols/relay/CHANGELOG.md index 125f51e4961..20852ac2553 100644 --- a/protocols/relay/CHANGELOG.md +++ b/protocols/relay/CHANGELOG.md @@ -1,6 +1,8 @@ ## 0.17.3 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). +- Fix `CircuitReq` to store the resource limits. + See [PR 5493](https://github.com/libp2p/rust-libp2p/pull/5493) ## 0.17.2 From f8d86b84d5d9eab4873127d1bf5a86c69cfa4ba4 Mon Sep 17 00:00:00 2001 From: Prabhat1308 Date: Fri, 19 Jul 2024 17:14:37 +0530 Subject: [PATCH 4/5] run cargo fmt Signed-off-by: Prabhat1308 --- protocols/relay/src/protocol/inbound_hop.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/protocols/relay/src/protocol/inbound_hop.rs b/protocols/relay/src/protocol/inbound_hop.rs index 09534c4c4a7..401c6258176 100644 --- a/protocols/relay/src/protocol/inbound_hop.rs +++ b/protocols/relay/src/protocol/inbound_hop.rs @@ -214,7 +214,12 @@ pub(crate) async fn handle_inbound_request( let dst = peer_id_res.map_err(|_| Error::ParsePeerId)?; - Either::Right(CircuitReq { dst, substream , max_circuit_duration, max_circuit_bytes}) + Either::Right(CircuitReq { + dst, + substream, + max_circuit_duration, + max_circuit_bytes, + }) } Type::STATUS => return Err(Error::UnexpectedTypeStatus), }; From f6fd9aada467f11b5f8ab5ea23aac606bb65acf0 Mon Sep 17 00:00:00 2001 From: Probot <94048855+Prabhat1308@users.noreply.github.com> Date: Fri, 19 Jul 2024 17:14:59 +0530 Subject: [PATCH 5/5] Update protocols/relay/CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: João Oliveira --- protocols/relay/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/relay/CHANGELOG.md b/protocols/relay/CHANGELOG.md index 20852ac2553..f49e57af0f7 100644 --- a/protocols/relay/CHANGELOG.md +++ b/protocols/relay/CHANGELOG.md @@ -1,7 +1,7 @@ ## 0.17.3 - Use `web-time` instead of `instant`. See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347). -- Fix `CircuitReq` to store the resource limits. +- Add resource limits to `CircuitReq` to be set See [PR 5493](https://github.com/libp2p/rust-libp2p/pull/5493) ## 0.17.2