Skip to content

Commit

Permalink
fix: allow relay to forward unlimited bytes
Browse files Browse the repository at this point in the history
Allow relay to forward unlimited bytes from one peer to another by checking if `max_circuit_bytes` equals to 0 before checking if `bytes_sent` exceeds `max_circuit_bytes`.
This will make current implementation follow the spec.
May close #5170.

Pull-Request: #5244.
  • Loading branch information
drHuangMHT authored Apr 4, 2024
1 parent 67ebcde commit fdddacc
Show file tree
Hide file tree
Showing 5 changed files with 9 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 @@ -96,7 +96,7 @@ libp2p-ping = { version = "0.44.0", path = "protocols/ping" }
libp2p-plaintext = { version = "0.41.0", path = "transports/plaintext" }
libp2p-pnet = { version = "0.24.0", path = "transports/pnet" }
libp2p-quic = { version = "0.10.2", path = "transports/quic" }
libp2p-relay = { version = "0.17.1", path = "protocols/relay" }
libp2p-relay = { version = "0.17.2", path = "protocols/relay" }
libp2p-rendezvous = { version = "0.14.0", path = "protocols/rendezvous" }
libp2p-request-response = { version = "0.26.2", 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.17.2

- Fix support for unlimited relay connection according to spec.
See [PR 5244](https://github.com/libp2p/rust-libp2p/pull/5244).

## 0.17.1

- Automatically register relayed addresses as external addresses.
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.17.1"
version = "0.17.2"
authors = ["Parity Technologies <[email protected]>", "Max Inden <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
2 changes: 1 addition & 1 deletion protocols/relay/src/copy_future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ where
let this = &mut *self;

loop {
if this.bytes_sent > this.max_circuit_bytes {
if this.max_circuit_bytes > 0 && this.bytes_sent > this.max_circuit_bytes {
return Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
"Max circuit bytes reached.",
Expand Down

0 comments on commit fdddacc

Please sign in to comment.