1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00

spam fix no2

This commit is contained in:
NoobishSVK
2024-11-03 20:41:42 +01:00
parent b0db24577b
commit 315fa4ba87

View File

@@ -417,6 +417,11 @@ wss.on('connection', (ws, request) => {
// Detect extremely fast spamming (more than 1 message in under 10ms)
if (now - lastMessageTime < 10) {
logWarn(`User \x1b[90m${clientIp}\x1b[0m is likely a bot or script spamming. Connection will be terminated immediately.`);
if (!serverConfig.webserver.banlist.includes(clientIp)) {
serverConfig.webserver.banlist.push(clientIp);
logInfo(`User \x1b[90m${clientIp}\x1b[0m has been added to the banlist due to extreme spam.`);
}
ws.close(1008, 'Bot-like behavior detected');
return;
}