Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protocols/relay: Limit inbound streams #2698

Merged
merged 11 commits into from
Jun 8, 2022
Prev Previous commit
Next Next commit
protocols/relay: Deny new circuits before accepting new circuits
mxinden committed Jun 8, 2022

Verified

This commit was signed with the committer’s verified signature.
mxinden Max Inden
commit b4103cbb379f0d9e7bfab740cfa95ee6f5316400
46 changes: 23 additions & 23 deletions protocols/relay/src/v2/relay/handler.rs
Original file line number Diff line number Diff line change
@@ -764,6 +764,29 @@ impl ConnectionHandler for Handler {
}
}

// Deny new circuits.
if let Poll::Ready(Some((circuit_id, dst_peer_id, result))) =
self.circuit_deny_futures.poll_next_unpin(cx)
{
match result {
Ok(()) => {
return Poll::Ready(ConnectionHandlerEvent::Custom(Event::CircuitReqDenied {
circuit_id,
dst_peer_id,
}));
}
Err(error) => {
return Poll::Ready(ConnectionHandlerEvent::Custom(
Event::CircuitReqDenyFailed {
circuit_id,
dst_peer_id,
error,
},
));
}
}
}

// Accept new circuits.
if let Poll::Ready(Some(result)) = self.circuit_accept_futures.poll_next_unpin(cx) {
match result {
@@ -825,29 +848,6 @@ impl ConnectionHandler for Handler {
}
}

// Deny new circuits.
if let Poll::Ready(Some((circuit_id, dst_peer_id, result))) =
self.circuit_deny_futures.poll_next_unpin(cx)
{
match result {
Ok(()) => {
return Poll::Ready(ConnectionHandlerEvent::Custom(Event::CircuitReqDenied {
circuit_id,
dst_peer_id,
}));
}
Err(error) => {
return Poll::Ready(ConnectionHandlerEvent::Custom(
Event::CircuitReqDenyFailed {
circuit_id,
dst_peer_id,
error,
},
));
}
}
}

// Check active reservation.
if let Some(Poll::Ready(())) = self
.active_reservation