summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaindropsSys <raindrops@equestria.dev>2023-09-26 08:18:15 +0200
committerRaindropsSys <raindrops@equestria.dev>2023-09-26 08:18:15 +0200
commitf2cdfa6a0480fd8c6a24597c60b4f719e535a9a6 (patch)
treeb76db71db813f03451696141f471900ed9f33d69
parent2af9c629b2d7abc293e08e8851f535c6feb69e64 (diff)
downloadchatroom-f2cdfa6a0480fd8c6a24597c60b4f719e535a9a6.tar.gz
chatroom-f2cdfa6a0480fd8c6a24597c60b4f719e535a9a6.tar.bz2
chatroom-f2cdfa6a0480fd8c6a24597c60b4f719e535a9a6.zip
Updated server/server.js (automated)
-rwxr-xr-xserver/server.js47
1 files changed, 0 insertions, 47 deletions
diff --git a/server/server.js b/server/server.js
index c100e13..48368a3 100755
--- a/server/server.js
+++ b/server/server.js
@@ -162,7 +162,6 @@ readline.question("Enter the IP address users would use to connect to the server
ws.ipAddress = parseAddress(req.socket.remoteAddress);
ws.userName = ws.address = null;
ws.lastPacket = 0;
- ws.rateLimitAttempts = [];
clients.push(ws);
@@ -210,51 +209,6 @@ readline.question("Enter the IP address users would use to connect to the server
ws.close();
}
- if (diff <= 75 && ws.publicKey && data.type !== "keyExchange" && data.type !== "ping") {
- ws.send(JSON.stringify({
- type: "encrypted",
- source: ws.address,
- message: encrypt(JSON.stringify({
- type: "system",
- date: new Date().getTime(),
- text: l("server/ratelimit", ws.lang)
- }), ws.publicKey)
- }));
- ws.rateLimitAttempts.push(new Date().getTime());
-
- log("User exceeded rate limit, last packet was " + diff + "ms ago, " + ws.rateLimitAttempts.filter(i => new Date().getTime() - i <= 60000).length + " recorded exceeds", ws.address);
-
- if (ws.rateLimitAttempts.filter(i => new Date().getTime() - i <= 60000).length > 5) {
- log("User exceeded rate limit trigger, banning them", ws.address);
-
- bans.push(ws.address);
- ws.rateLimitAttempts = [];
-
- ws.send(JSON.stringify({
- type: "banned"
- }));
- ws.close();
-
- for (let socket of clients) {
- try {
- socket.send(JSON.stringify({
- type: "encrypted",
- source: ws.address,
- message: encrypt(JSON.stringify({
- type: "system",
- date: new Date().getTime(),
- text: l("server/autoban", socket.lang).replace("%1", ws.address)
- }), socket.publicKey)
- }));
- } catch (e) {}
- }
-
- fs.writeFileSync("./config/bans.json", JSON.stringify(bans));
- }
-
- return;
- }
-
if (bans.includes(ws.address)) {
log("Kicking user because they are banned, how did they even send a message?", ws.address);
@@ -490,7 +444,6 @@ readline.question("Enter the IP address users would use to connect to the server
`${l("commands/lookup/ip", ws.lang)} ${selected.ipAddress}\n` +
`${l("commands/lookup/language", ws.lang)} ${l("_locale", selected.lang)}\n` +
`${l("commands/lookup/session", ws.lang)} ${selected.id}\n` +
- `${l("commands/lookup/ratelimit", ws.lang)} ${selected.rateLimitAttempts.length}\n` +
`${l("commands/lookup/op", ws.lang)} ${operators.includes(selected.userName) ? l("commands/lookup/yes", ws.lang) : l("commands/lookup/no", ws.lang)}`
}), ws.publicKey)
}));