diff options
author | marzavec <admin@marzavec.com> | 2018-03-11 07:41:17 +0100 |
---|---|---|
committer | marzavec <admin@marzavec.com> | 2018-03-11 07:41:26 +0100 |
commit | 7d8220d838f82f7ad1ffedbcbd3b955aef6d71a2 (patch) | |
tree | c73d26f8d6e3b2c7af23e4afcd55ea7ceccf3596 /server/src/core | |
parent | Merge pull request #1 from MinusGix/master (diff) | |
download | hackchat-7d8220d838f82f7ad1ffedbcbd3b955aef6d71a2.tar.gz hackchat-7d8220d838f82f7ad1ffedbcbd3b955aef6d71a2.zip |
stabilized modules and server cmd field
Diffstat (limited to '')
-rw-r--r-- | server/src/core/server.js | 16 |
1 files changed, 10 insertions, 6 deletions
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; } |