Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions protocols/relay/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## 0.17.3
- Use `web-time` instead of `instant`.
See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347).
- Add resource limits to `CircuitReq` to be set
See [PR 5493](https://github.com/libp2p/rust-libp2p/pull/5493)

## 0.17.2

Expand Down
19 changes: 17 additions & 2 deletions protocols/relay/src/protocol/inbound_hop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ impl ReservationReq {
pub struct CircuitReq {
dst: PeerId,
substream: Framed<Stream, quick_protobuf_codec::Codec<proto::HopMessage>>,
max_circuit_duration: Duration,
max_circuit_bytes: u64,
}

impl CircuitReq {
Expand All @@ -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),
};

Expand Down Expand Up @@ -204,7 +214,12 @@ 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),
};
Expand Down