node: rate limiter for channel reads
This introduces rate limits for the ChannelReader to limit DDoS attacks and
attempts to upload repositories that are larger than a node is will to permit.
The limiter sets the total number of bytes it is will to accept in a single exchange, defaulting to 500MB. This means that initial fetches will prevent large repositories, but is plenty for new packfile data to be sent in subsequent fetch exchanges.
The limit can be configured within the node’s config file, under the limits.
10 files changed
+237
-20
f13afe49
→
a90aabb1
modified Cargo.lock
@@ -1,6 +1,6 @@
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -309,6 +309,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -2173,6 +2182,7 @@ version = "0.14.0"
|
|
|
|
|
|
| + | |
|
|
|
|
|
modified radicle-cli/examples/rad-config.md
@@ -47,7 +47,8 @@ $ rad config
|
|
|
|
|
|
| - | |
| + | |
| + | |
|
|
|
|
|
modified radicle-node/src/service.rs
@@ -1098,7 +1098,13 @@ where
|
|
|
|
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
modified radicle-node/src/service/io.rs
@@ -2,6 +2,7 @@ use std::collections::VecDeque;
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -30,6 +31,8 @@ pub enum Io {
|
|
|
|
|
|
| + | |
| + | |
|
|
|
|
|
@@ -124,6 +127,7 @@ impl Outbox {
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -143,6 +147,7 @@ impl Outbox {
|
|
|
|
|
|
| + | |
|
|
|
|
|
modified radicle-node/src/tests/e2e.rs
@@ -1493,3 +1493,44 @@ fn test_multiple_offline_inits() {
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
modified radicle-node/src/wire/protocol.rs
@@ -35,7 +35,7 @@ use crate::wire::frame;
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -128,22 +128,22 @@ impl Streams {
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
|
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
|
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
|
|
|
|
|
@@ -762,8 +762,12 @@ where
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -1062,6 +1066,7 @@ where
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -1076,7 +1081,8 @@ where
|
|
|
|
|
|
| - | |
| + | |
| + | |
|
|
|
|
|
modified radicle-node/src/worker.rs
@@ -23,7 +23,7 @@ use crate::service::policy;
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
modified radicle-node/src/worker/channels.rs
@@ -4,6 +4,7 @@ use std::ops::Deref;
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -14,6 +15,32 @@ use crate::wire::StreamId;
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -92,20 +119,23 @@ impl<T: AsRef<[u8]>> Channels<T> {
|
|
|
|
|
|
| - | |
| + | |
|
|
| - | |
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
|
|
|
|
|
@@ -123,12 +153,41 @@ impl<T: AsRef<[u8]>> Channels<T> {
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
|
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -140,11 +199,16 @@ impl<T> Deref for ChannelReader<T> {
|
|
|
|
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -152,6 +216,7 @@ impl<T: AsRef<[u8]>> ChannelReader<T> {
|
|
|
|
|
|
| + | |
|
|
|
|
|
modified radicle/Cargo.toml
@@ -16,6 +16,7 @@ logger = ["colored", "chrono"]
|
|
|
|
|
|
| + | |
|
|
|
|
|
modified radicle/src/node/config.rs
@@ -1,6 +1,7 @@
|
|
| - | |
|
|
| + | |
| + | |
|
|
|
|
|
@@ -114,6 +115,9 @@ pub struct Limits {
|
|
|
|
|
|
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -126,10 +130,88 @@ impl Default for Limits {
|
|
|
|
|
|
| + | |
|
|
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|