From a180c3a301d26b3eb3a5d2c05ec48be74abd1f2c Mon Sep 17 00:00:00 2001 From: sven Tan Date: Wed, 9 Oct 2024 08:49:29 +0800 Subject: [PATCH] Limiter/logs (#2737) add doc & log --- crates/rooch-config/src/lib.rs | 8 ++++++++ crates/rooch-rpc-server/src/service/blocklist.rs | 5 +++++ sdk/typescript/templates/react-counter/src/main.tsx | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/rooch-config/src/lib.rs b/crates/rooch-config/src/lib.rs index d2e604d6f..a57b16315 100644 --- a/crates/rooch-config/src/lib.rs +++ b/crates/rooch-config/src/lib.rs @@ -135,9 +135,17 @@ pub struct RoochOpt { #[clap(long, default_value_t, value_enum)] pub service_status: ServiceStatus, + /// Set quota size that defines how many requests can occur + /// before the governor middleware starts blocking requests from an IP address and + /// clients have to wait until the elements of the quota are replenished. + /// + /// **The burst_size must not be zero.** #[clap(long)] pub traffic_burst_size: Option, + /// Set the interval after which one element of the quota is replenished in seconds. + /// + /// **The interval must not be zero.** #[clap(long)] pub traffic_per_second: Option, diff --git a/crates/rooch-rpc-server/src/service/blocklist.rs b/crates/rooch-rpc-server/src/service/blocklist.rs index 40b12f21e..5623e1821 100644 --- a/crates/rooch-rpc-server/src/service/blocklist.rs +++ b/crates/rooch-rpc-server/src/service/blocklist.rs @@ -157,6 +157,11 @@ where } }, }; + + tracing::debug!("requset headers: {:?}", &req.headers()); + tracing::debug!("client ip: {:?}", &client); + tracing::debug!("proxied client ip: {:?}", &proxied_client); + let s = self.check_impl(&client, &proxied_client); // Extraction worked, let's check blocklist needed. diff --git a/sdk/typescript/templates/react-counter/src/main.tsx b/sdk/typescript/templates/react-counter/src/main.tsx index 3430a5053..fb5043d6f 100644 --- a/sdk/typescript/templates/react-counter/src/main.tsx +++ b/sdk/typescript/templates/react-counter/src/main.tsx @@ -14,8 +14,8 @@ ReactDOM.createRoot(document.getElementById("root")!).render( - - + +