Rate limit the amount of inbound connections (#2928)
* add sleep to `accept_inbound_connections()` * Expand docs * Expand comments again Co-authored-by: teor <teor@riseup.net>
This commit is contained in:
parent
35290db052
commit
ad5f5ff24a
|
|
@ -415,6 +415,16 @@ where
|
|||
.instrument(handshaker_span),
|
||||
);
|
||||
}
|
||||
|
||||
// Only spawn one inbound connection handshake per `MIN_PEER_CONNECTION_INTERVAL`.
|
||||
// But clear out failed connections as fast as possible.
|
||||
//
|
||||
// If there is a flood of connections,
|
||||
// this stops Zebra overloading the network with handshake data.
|
||||
//
|
||||
// Zebra can't control how many queued connections are waiting,
|
||||
// but most OSes also limit the number of queued inbound connections on a listener port.
|
||||
tokio::time::sleep(constants::MIN_PEER_CONNECTION_INTERVAL).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue