Add rate-limit exempt client IPs#2856
Add rate-limit exempt client IPs#2856simpliq-marvin wants to merge 1 commit intopi-hole:developmentfrom
Conversation
80431d9 to
756667e
Compare
|
Please base on and target Why did you include
This would be a new option, there is no legacy to handle here. |
756667e to
4b5fd42
Compare
|
Thanks for calling that out, you’re right on both points. I opened this against the wrong base branch. On the config side, I was adding legacy syntax for the new option, but of course that syntax never existed. My bad. I’ve removed that, rebased onto |
DL6ER
left a comment
There was a problem hiding this comment.
You are adding this into the hottest path Pi-hole has and my preliminary measurements show that this affects performance notably. Instead of iterating over the array of JSON strings, converting them twice to IPv4 and IPv6 (once for the client IP and then for every IP in the array) and doing memory comparisons, this should rather live in a dedicated function in a suitable thread outside the hot path. This can then run periodically and simply set some bool inside the struct clientsData so that it can be checked in the hot-path without any performance impact.
|
Thanks, good catch. I agree the current version is doing too much work in the query hot path. I’m reworking this so exemption matching is resolved when client/config state is created or refreshed, and query handling only reads cached per-client state. I’ll push the revision once I’ve validated the build/tests locally. |
4b5fd42 to
84cf6fe
Compare
Signed-off-by: simpliq-marvin <[email protected]>
84cf6fe to
0451d8e
Compare
|
I’ve pushed the rework. The exemption check is now cached per-client state instead of being recomputed in I’ve also tested it on a Raspberry Pi build from this PR revision. A laptop reboot produced a burst well above the configured Config reload/replacement also refreshes the cached exemption state. |
This adds a small escape hatch for setups where a trusted client can legitimately generate short DNS bursts and ends up tripping Pi-hole's per-client rate limiting.
A practical example is a work laptop coming back after a restart, VPN reconnect, or similar network reset. In that state it can generate a short burst of DNS traffic that is genuine, but still large enough to hit the global per-client limit. For users who want to keep rate limiting enabled overall, this adds a narrow opt-in way to exempt specific trusted clients.
The change adds a new
dns.rateLimit.exemptIPssetting. When a client IP matches one of the configured addresses exactly, that client bypasses the per-client rate-limit check. Other clients still use the existing rate-limit behaviour unchanged.What is included here:
dns.rateLimit.exemptIPsValidation:
1000 queries / 60s, an exempt client reached1663and1853queries in FTL-aligned 60s buckets, with a rolling 60s peak of2140, without being rate-limitedRelated user report:
This is intentionally narrow. Matching is exact by IP address, and only applies when rate limiting is enabled.