From 7d8220d838f82f7ad1ffedbcbd3b955aef6d71a2 Mon Sep 17 00:00:00 2001 From: marzavec Date: Sat, 10 Mar 2018 22:41:17 -0800 Subject: stabilized modules and server cmd field --- server/src/core/server.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'server/src/core') diff --git a/server/src/core/server.js b/server/src/core/server.js index c16aec8..98763af 100644 --- a/server/src/core/server.js +++ b/server/src/core/server.js @@ -63,7 +63,6 @@ class server extends wsServer { * @param {String} data Message sent from client */ handleData (socket, data) { - // TODO: Rate limit here // Don't penalize yet, but check whether IP is rate-limited if (this._police.frisk(socket.remoteAddress, 0)) { this.reply({ cmd: 'warn', text: "Your IP is being rate-limited or blocked." }, socket); @@ -87,18 +86,23 @@ class server extends wsServer { socket.close(); } - if (args === null) + if (args === null) { return; + } - if (typeof args.cmd === 'undefined' || args.cmd == 'ping') + if (typeof args.cmd === 'undefined' || args.cmd == 'ping') { return; + } - var cmd = args.cmd; + if (typeof args.cmd !== 'string') { + return; + } - if (typeof socket.channel === 'undefined' && cmd !== 'join') + if (typeof socket.channel === 'undefined' && args.cmd !== 'join') { return; + } - if (typeof this._cmdBlacklist[cmd] === 'function') { + if (typeof this._cmdBlacklist[args.cmd] === 'function') { return; } -- cgit v1.2.1