make cd based on subnet if not logged in
This commit is contained in:
parent
a08ba00940
commit
279819eac0
|
@ -38,7 +38,15 @@ export default function allowPlace(
|
||||||
const isalKey = `${ALLOWED_PREFIX}:${ip}`;
|
const isalKey = `${ALLOWED_PREFIX}:${ip}`;
|
||||||
const captKey = (CAPTCHA_TIME >= 0) ? `${CAPTCHA_PREFIX}:${ip}` : 'nope';
|
const captKey = (CAPTCHA_TIME >= 0) ? `${CAPTCHA_PREFIX}:${ip}` : 'nope';
|
||||||
const ipCdKey = `${PREFIX}:${canvasId}:ip:${ip}`;
|
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 chunkKey = `ch:${canvasId}:${i}:${j}`;
|
||||||
const cc = country || 'xx';
|
const cc = country || 'xx';
|
||||||
const rankset = (ranked) ? RANKED_KEY : 'nope';
|
const rankset = (ranked) ? RANKED_KEY : 'nope';
|
||||||
|
@ -67,6 +75,10 @@ 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);
|
||||||
|
} 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;
|
const cooldown = ttl < 0 ? 0 : ttl;
|
||||||
return cooldown;
|
return cooldown;
|
||||||
|
|
|
@ -22,7 +22,8 @@ async function banme(req, res) {
|
||||||
reason = 'Captcha Solving Script';
|
reason = 'Captcha Solving Script';
|
||||||
}
|
}
|
||||||
const ip = getIPFromRequest(req);
|
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(
|
await banIP(
|
||||||
getIPv6Subnet(ip),
|
getIPv6Subnet(ip),
|
||||||
reason,
|
reason,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user