From c38227b2fe5c3522ec965c44220bd79a34506fbd Mon Sep 17 00:00:00 2001 From: FloppyMacguffum Date: Tue, 19 Nov 2024 21:06:27 -0800 Subject: [PATCH 1/3] Fixes to part of issue #35 --- src/proxy/Proxy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proxy/Proxy.ts b/src/proxy/Proxy.ts index f002e2b..501042e 100644 --- a/src/proxy/Proxy.ts +++ b/src/proxy/Proxy.ts @@ -189,7 +189,7 @@ export class Proxy extends EventEmitter { } }, this.LOGIN_TIMEOUT); try { - if (firstPacket.toString() === "Accept: MOTD") { + if (firstPacket.toString().toLowerCase() === "accept: motd") { if (!this.ratelimit.motd.consume(req.socket.remoteAddress).success) { return ws.close(); } From c0bf9b3254a2c2680b4b5fd72ad414559abc431a Mon Sep 17 00:00:00 2001 From: FloppyMacguffum Date: Thu, 28 Nov 2024 10:46:18 -0800 Subject: [PATCH 2/3] Took a tip from lax1dude. --- src/proxy/Proxy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proxy/Proxy.ts b/src/proxy/Proxy.ts index 501042e..b918f35 100644 --- a/src/proxy/Proxy.ts +++ b/src/proxy/Proxy.ts @@ -189,7 +189,7 @@ export class Proxy extends EventEmitter { } }, this.LOGIN_TIMEOUT); try { - if (firstPacket.toString().toLowerCase() === "accept: motd") { + if (new RegExp("accept: motd", "i").test(firstPacket.toString())) { if (!this.ratelimit.motd.consume(req.socket.remoteAddress).success) { return ws.close(); } From cd9f8756ee1fa5ab478c3e4f6233b0384176aadf Mon Sep 17 00:00:00 2001 From: FloppyMacguffum Date: Thu, 28 Nov 2024 21:56:48 -0800 Subject: [PATCH 3/3] Switched to literal regex notation for some MOTD logic, no temp object on ping --- src/proxy/Proxy.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/proxy/Proxy.ts b/src/proxy/Proxy.ts index b918f35..b20c4c5 100644 --- a/src/proxy/Proxy.ts +++ b/src/proxy/Proxy.ts @@ -30,6 +30,7 @@ import { SkinServer } from "./skins/SkinServer.js"; let instanceCount = 0; const chalk = new Chalk({ level: 2 }); +const motdMatcher = /accept: motd/i; export class Proxy extends EventEmitter { public packetRegistry: Map< @@ -189,7 +190,7 @@ export class Proxy extends EventEmitter { } }, this.LOGIN_TIMEOUT); try { - if (new RegExp("accept: motd", "i").test(firstPacket.toString())) { + if (motdMatcher.test(firstPacket.toString())) { if (!this.ratelimit.motd.consume(req.socket.remoteAddress).success) { return ws.close(); }