* repeater: onAnonDataRecv(), now rejecting non-ASCII password (preparing for future request codes)

* repeater: DISCOVER requests now with a simple RateLimiter (max 4, every 2 minutes)
This commit is contained in:
Scott Powell
2025-11-06 20:15:01 +11:00
parent cf547da857
commit 09eab330a2
3 changed files with 36 additions and 4 deletions

View File

@@ -0,0 +1,23 @@
#pragma once
#include <stdint.h>
class RateLimiter {
uint32_t _start_timestamp;
uint32_t _secs;
uint16_t _maximum, _count;
public:
RateLimiter(uint16_t maximum, uint32_t secs): _maximum(maximum), _secs(secs), _start_timestamp(0), _count(0) { }
bool allow(uint32_t now) {
if (now < _start_timestamp + _secs) {
_count++;
if (_count > _maximum) return false; // deny
} else { // time window now expired
_start_timestamp = now;
_count = 1;
}
return true;
}
};