From dc0699e9537cf5f401ebea8e2d46fd55277d113e Mon Sep 17 00:00:00 2001 From: BrainFooLong Date: Sun, 10 Feb 2019 18:38:59 +0100 Subject: [PATCH] fixed deprecated warnings for buffer --- CHANGELOG.md | 4 ++++ README.md | 3 +++ package.json | 2 +- src/rcon.js | 12 ++++++------ 4 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2521583 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +# Changelog + +- 10.02.2019 + - fixed deprecated warnings for newer nodejs versions diff --git a/README.md b/README.md index dfb5f09..54a2145 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,9 @@ If you like to buy some coffee, i will appriciate it. You can do this on [Patreo ## Widgets The widgets are powerful, they deserve an extra header here. All dashboard things are written in widgets. From the simplest to the most powerful tool, widgets are the way to go. They are some sort of "High level" programs inside the rcon web admin. You don't have to dig much into the code to write widgets. It's basically HTML and JS. +## Requirements +- NodeJS min. v5.10.0 + ## Installation Windows * Download and install node.js (https://nodejs.org) * Download zip repository and unpack wherever you want diff --git a/package.json b/package.json index daacad2..9665adb 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "BrainFooLong (https://github.com/brainfoolong/rcon-web-admin)", "name": "rcon-web-admin", "description": "Self hosted, online RCON administration tool for your server.", - "version": "0.13.2", + "version": "0.13.3", "license": "MIT", "main": "src/main.js", "repository": { diff --git a/src/rcon.js b/src/rcon.js index 6d82d3a..2ea98c0 100644 --- a/src/rcon.js +++ b/src/rcon.js @@ -57,13 +57,13 @@ function Rcon(host, port, server) { * Receive data buffer * @type {Buffer} */ - this.dataBuffer = new Buffer(0); + this.dataBuffer = Buffer.alloc(0); /** * The received body buffer * @type string */ - this.bodyBuffer = new Buffer(0); + this.bodyBuffer = Buffer.alloc(0); /** * Send queue @@ -237,7 +237,7 @@ Rcon.prototype.send = function (cmd, user, log, callback, type) { type = Rcon.SERVERDATA_EXECCOMMAND; } if (!Buffer.isBuffer(cmd)) { - cmd = new Buffer(cmd); + cmd = Buffer.from(cmd); } // for auth request we handle a special callback if (type == Rcon.SERVERDATA_AUTH) { @@ -256,7 +256,7 @@ Rcon.prototype.send = function (cmd, user, log, callback, type) { // write an extra empty request to be able to find multipart message boundings // minecraft dont have multipart packages so we need no end if (type != Rcon.SERVERDATA_AUTH && self.server.serverData.game != "minecraft") { - self.socket.write(self._pack(self.packetId, Rcon.SERVERDATA_RESPONSE_VALUE, new Buffer(0))); + self.socket.write(self._pack(self.packetId, Rcon.SERVERDATA_RESPONSE_VALUE, Buffer.alloc(0))); self.packetId = self.nextPacketId(); } }); @@ -328,7 +328,7 @@ Rcon.prototype._data = function () { } catch (e) { console.error(new Date(), "RconServer [" + serverName + "]: send callback error", e, e.stack); } - this.bodyBuffer = new Buffer(0); + this.bodyBuffer = Buffer.alloc(0); } this.sendBlocked = false; this.processQueue(); @@ -353,7 +353,7 @@ Rcon.prototype._data = function () { * @private */ Rcon.prototype._pack = function (id, type, body) { - var buf = new Buffer(body.length + 14); + var buf = Buffer.alloc(body.length + 14); buf.writeInt32LE(body.length + 10, 0); buf.writeInt32LE(id, 4); buf.writeInt32LE(type, 8);