adjust cd changes

This commit is contained in:
HF 2022-09-23 17:02:12 +02:00
parent a6b9c6099d
commit 08fef6f6dd

View File

@ -41,9 +41,13 @@ export default function allowPlace(
let idCdKey; let idCdKey;
if (id) { if (id) {
idCdKey = `${PREFIX}:${canvasId}:id:${id}`; idCdKey = `${PREFIX}:${canvasId}:id:${id}`;
/*
* cooldown by subnet should be more restrictive
*
} else if (ip.includes('.')) { } else if (ip.includes('.')) {
const ips = ip.slice(0, ip.lastIndexOf('.')); const ips = ip.slice(0, ip.lastIndexOf('.'));
idCdKey = `${PREFIX}:${canvasId}:ips:${ips}`; idCdKey = `${PREFIX}:${canvasId}:ips:${ips}`;
*/
} else { } else {
idCdKey = 'nope'; idCdKey = 'nope';
} }
@ -75,10 +79,14 @@ export async function getCoolDown(
if (id) { if (id) {
const ttlid = await client.pTTL(`${PREFIX}:${canvasId}:id:${id}`); const ttlid = await client.pTTL(`${PREFIX}:${canvasId}:id:${id}`);
ttl = Math.max(ttl, ttlid); ttl = Math.max(ttl, ttlid);
/*
* cooldown by subnet should be more restrictive
*
} else if (ip.includes('.')) { } else if (ip.includes('.')) {
const ips = ip.slice(0, ip.lastIndexOf('.')); const ips = ip.slice(0, ip.lastIndexOf('.'));
const ttlid = await client.pTTL(`${PREFIX}:${canvasId}:ips:${ips}`); const ttlid = await client.pTTL(`${PREFIX}:${canvasId}:ips:${ips}`);
ttl = Math.max(ttl, ttlid); ttl = Math.max(ttl, ttlid);
*/
} }
const cooldown = ttl < 0 ? 0 : ttl; const cooldown = ttl < 0 ? 0 : ttl;
return cooldown; return cooldown;