Increase failedAuthAttempts eviction limit from 50k to 200k

This commit is contained in:
Timo
2026-06-13 04:38:22 +02:00
parent 9f553b4f8f
commit 6ba5e1b10b
+6 -6
View File
@@ -148,22 +148,22 @@ function checkAuthRate(ip, roomId) {
}
function recordAuthFailure(ip, roomId) {
if (failedAuthAttempts.size > 50000) {
if (failedAuthAttempts.size > 200000) {
const now = Date.now();
// 1. Clear expired entries (> 15 mins)
for (const [key, record] of failedAuthAttempts.entries()) {
if (now - record.lastAttempt > 15 * 60 * 1000) {
failedAuthAttempts.delete(key);
} else {
break; // Since entries are insertion-ordered by time, all subsequent entries are newer
break;
}
}
// 2. If still over 50k, perform LRU-style eviction on the oldest 10,000 entries (first items in Map order)
if (failedAuthAttempts.size > 50000) {
log('SECURITY', 'failedAuthAttempts size exceeded 50000. Performing insertion-order eviction.');
// 2. If still over 200k, perform LRU-style eviction on the oldest 10,000 entries (first items in Map order)
if (failedAuthAttempts.size > 200000) {
log('SECURITY', 'failedAuthAttempts size exceeded 200000. Performing insertion-order eviction.');
for (const [key] of failedAuthAttempts.entries()) {
if (failedAuthAttempts.size <= 40000) {
if (failedAuthAttempts.size <= 190000) {
break;
}
failedAuthAttempts.delete(key);