allow method
- String source
Implementation
bool allow(String source) {
final now = _now();
final cutoff = now.subtract(window);
_attempts.removeWhere((_, attempts) {
attempts.removeWhere((attempt) => !attempt.isAfter(cutoff));
return attempts.isEmpty;
});
if (!_attempts.containsKey(source) &&
_attempts.length >= maxTrackedSources) {
return false;
}
final attempts = _attempts.putIfAbsent(source, () => []);
if (attempts.length >= maxAttempts) return false;
attempts.add(now);
return true;
}