From: Vladimír Čunát Date: Wed, 18 Dec 2024 11:01:10 +0000 (+0100) Subject: kr_request: add a .ratelimited flag X-Git-Tag: v6.0.10~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96599df7daa62db2361ff8e8097730284832ba0b;p=thirdparty%2Fknot-resolver.git kr_request: add a .ratelimited flag This makes it simpler for other parts of resolver to react to this situation, e.g. custom modules pushing the information to analytics. --- diff --git a/daemon/lua/kres-gen-33.lua b/daemon/lua/kres-gen-33.lua index e8adbda63..9bf16b7f4 100644 --- a/daemon/lua/kres-gen-33.lua +++ b/daemon/lua/kres-gen-33.lua @@ -250,6 +250,7 @@ struct kr_request { _Bool answ_validated; _Bool auth_validated; _Bool stale_accounted; + _Bool ratelimited; uint8_t rank; struct kr_rplan rplan; trace_log_f trace_log; diff --git a/daemon/ratelimiting.c b/daemon/ratelimiting.c index 996beaaf6..d182658e4 100644 --- a/daemon/ratelimiting.c +++ b/daemon/ratelimiting.c @@ -189,6 +189,7 @@ bool ratelimiting_request_begin(struct kr_request *req) } } + req->ratelimited = true; // we set this even on dry_run if (ratelimiting->dry_run) return false; // perform limiting diff --git a/lib/resolve.h b/lib/resolve.h index b3e6614d2..ef4f3f467 100644 --- a/lib/resolve.h +++ b/lib/resolve.h @@ -265,6 +265,7 @@ struct kr_request { bool answ_validated; /**< internal to validator; beware of caching, etc. */ bool auth_validated; /**< see answ_validated ^^ ; TODO */ bool stale_accounted; + bool ratelimited; /**< this request shot over the rate limit */ /** Overall rank for the request. *