diff --git a/src/data/redis/cooldown.js b/src/data/redis/cooldown.js index 27dbf9b..f5acf07 100644 --- a/src/data/redis/cooldown.js +++ b/src/data/redis/cooldown.js @@ -38,7 +38,15 @@ export default function allowPlace( const isalKey = `${ALLOWED_PREFIX}:${ip}`; const captKey = (CAPTCHA_TIME >= 0) ? `${CAPTCHA_PREFIX}:${ip}` : 'nope'; const ipCdKey = `${PREFIX}:${canvasId}:ip:${ip}`; - const idCdKey = (id) ? `${PREFIX}:${canvasId}:id:${id}` : 'nope'; + let idCdKey; + if (id) { + idCdKey = `${PREFIX}:${canvasId}:id:${id}`; + } else if (ip.includes('.')) { + const ips = ip.slice(0, ip.lastIndexOf('.')); + idCdKey = `${PREFIX}:${canvasId}:ips:${ips}`; + } else { + idCdKey = 'nope'; + } const chunkKey = `ch:${canvasId}:${i}:${j}`; const cc = country || 'xx'; const rankset = (ranked) ? RANKED_KEY : 'nope'; @@ -67,6 +75,10 @@ export async function getCoolDown( if (id) { const ttlid = await client.pTTL(`${PREFIX}:${canvasId}:id:${id}`); ttl = Math.max(ttl, ttlid); + } else if (ip.includes('.')) { + const ips = ip.slice(0, ip.lastIndexOf('.')); + const ttlid = await client.pTTL(`${PREFIX}:${canvasId}:ips:${ips}`); + ttl = Math.max(ttl, ttlid); } const cooldown = ttl < 0 ? 0 : ttl; return cooldown; diff --git a/src/routes/api/banme.js b/src/routes/api/banme.js index 02b4344..348ac0a 100644 --- a/src/routes/api/banme.js +++ b/src/routes/api/banme.js @@ -22,7 +22,8 @@ async function banme(req, res) { reason = 'Captcha Solving Script'; } const ip = getIPFromRequest(req); - logger.info(`AUTOBAN ${ip} of user ${req.user.id}`); + // eslint-disable-next-line max-len + logger.info(`AUTOBAN ${code}${ip} of user ${req.user.id} with ua "${req.headers['user-agent']}"`); await banIP( getIPv6Subnet(ip), reason,