Skip to content

Commit 25dd797

Browse files
authored
Apply InboundTrafficLimitHandler only if max bytes > 0 (#416)
1 parent 33ffc1a commit 25dd797

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

libp2p/src/main/java/io/libp2p/protocol/circuit/CircuitHopProtocol.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,15 @@ public void onMessage(@NotNull Stream stream, Circuit.HopMessage msg) {
315315
new CircuitStopProtocol.StopRemover());
316316

317317
// connect these streams with time + bytes enforcement
318-
fromRequestor.pushHandler(new InboundTrafficLimitHandler(resv.maxBytes));
318+
if (resv.maxBytes > 0) {
319+
fromRequestor.pushHandler(new InboundTrafficLimitHandler(resv.maxBytes));
320+
}
319321
fromRequestor.pushHandler(
320322
new TotalTimeoutHandler(
321323
Duration.of(resv.durationSeconds, ChronoUnit.SECONDS)));
322-
toTarget.pushHandler(new InboundTrafficLimitHandler(resv.maxBytes));
324+
if (resv.maxBytes > 0) {
325+
toTarget.pushHandler(new InboundTrafficLimitHandler(resv.maxBytes));
326+
}
323327
toTarget.pushHandler(
324328
new TotalTimeoutHandler(
325329
Duration.of(resv.durationSeconds, ChronoUnit.SECONDS)));

0 commit comments

Comments
 (0)