Fix rate limiter

This commit is contained in:
artur 2024-02-09 15:43:35 +03:00
parent e3f41b338c
commit 0b748ed35b

View File

@ -460,7 +460,7 @@ function getMinPow(name, req) {
const ip = req.header('x-real-ip') || req.ip
// have a record for this ip?
const { pow: lastPow = 0, tm = 0 } = ipNamePows.get(ip) || {};
let { pow: lastPow = 0, tm = 0 } = ipNamePows.get(ip) || {};
console.log("minPow", { name, ip, lastPow, tm, headers: req.headers });
if (lastPow) {
// refill: reduce the pow threshold once per passed period