[Bot detection] Regenerate challenge only if served
What would you like to be added?
Hey, I just activated the bot detection in my setup and saw the cpu spikes from the regeneration of the challenge. I found that https://github.com/crowdsecurity/crowdsec/pull/4674 is already addressing this and with the key_rotation_interval I could bring down CPU usage even more.
One more idea though: Skip the per-epoch signing-key rotation and JS re-obfuscation pass if the current epoch's challenge has never been served to a client.
Why is this needed?
On an instance where the challenge is scoped to a few hosts (e.g. in homelabs), the rotation runs on a fixed schedule regardless of whether any client was ever challenged. On my system, each pass costs a full CPU core for several seconds, which dominates the process's total CPU usage on an otherwise quiet machine.
Source: crowdsecurity/crowdsec