Merge pull request #183 from davestephens/0.0.9-node10

Node.js 10 Upgrade. Bazinga!
This commit is contained in:
Bryan Ashby 2018-04-29 17:31:18 -06:00 committed by GitHub
commit b2ae81c59e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 2711 additions and 47 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
*.pem *.pem
# Various directories # Various directories
config/config.hjson
logs/ logs/
db/ db/
dropfiles/ dropfiles/

View File

@ -78,11 +78,11 @@ module.exports = class ArchiveUtil {
Object.keys(Config.fileTypes).forEach(mimeType => { Object.keys(Config.fileTypes).forEach(mimeType => {
const fileType = Config.fileTypes[mimeType]; const fileType = Config.fileTypes[mimeType];
if(fileType.sig) { if(fileType.sig) {
fileType.sig = new Buffer(fileType.sig, 'hex'); fileType.sig = Buffer.from(fileType.sig, 'hex');
fileType.offset = fileType.offset || 0; fileType.offset = fileType.offset || 0;
// :TODO: this is broken: sig is NOT this long, it's sig.length long; offset needs to allow for -negative values as well // :TODO: this is broken: sig is NOT this long, it's sig.length long; offset needs to allow for -negative values as well
const sigLen =fileType.offset + fileType.sig.length; const sigLen = fileType.offset + fileType.sig.length;
if(sigLen > this.longestSignature) { if(sigLen > this.longestSignature) {
this.longestSignature = sigLen; this.longestSignature = sigLen;
} }
@ -120,7 +120,7 @@ module.exports = class ArchiveUtil {
return cb(err); return cb(err);
} }
const buf = new Buffer(this.longestSignature); const buf = Buffer.alloc(this.longestSignature);
fs.read(fd, buf, 0, buf.length, 0, (err, bytesRead) => { fs.read(fd, buf, 0, buf.length, 0, (err, bytesRead) => {
if(err) { if(err) {
return cb(err); return cb(err);

View File

@ -288,7 +288,7 @@ function display(client, art, options, cb) {
} }
if(!options.disableMciCache) { if(!options.disableMciCache) {
artHash = xxhash.hash(new Buffer(art), 0xCAFEBABE); artHash = xxhash.hash(Buffer.from(art), 0xCAFEBABE);
// see if we have a mciMap cached for this art // see if we have a mciMap cached for this art
if(client.mciCache) { if(client.mciCache) {

View File

@ -374,7 +374,7 @@ exports.getModule = class TransferFileModule extends MenuModule {
// needed for things like sz/rz // needed for things like sz/rz
if(external.escapeTelnet) { if(external.escapeTelnet) {
const tmp = data.toString('binary').replace(/\xff{2}/g, '\xff'); // de-escape const tmp = data.toString('binary').replace(/\xff{2}/g, '\xff'); // de-escape
externalProc.write(new Buffer(tmp, 'binary')); externalProc.write(Buffer.from(tmp, 'binary'));
} else { } else {
externalProc.write(data); externalProc.write(data);
} }
@ -384,7 +384,7 @@ exports.getModule = class TransferFileModule extends MenuModule {
// needed for things like sz/rz // needed for things like sz/rz
if(external.escapeTelnet) { if(external.escapeTelnet) {
const tmp = data.toString('binary').replace(/\xff/g, '\xff\xff'); // escape const tmp = data.toString('binary').replace(/\xff/g, '\xff\xff'); // escape
this.client.term.rawWrite(new Buffer(tmp, 'binary')); this.client.term.rawWrite(Buffer.from(tmp, 'binary'));
} else { } else {
this.client.term.rawWrite(data); this.client.term.rawWrite(data);
} }

View File

@ -19,7 +19,7 @@ module.exports = class FNV1a {
} }
if(_.isString(data)) { if(_.isString(data)) {
data = new Buffer(data); data = Buffer.from(data);
} }
if(!Buffer.isBuffer(data)) { if(!Buffer.isBuffer(data)) {
@ -38,7 +38,7 @@ module.exports = class FNV1a {
digest(encoding) { digest(encoding) {
encoding = encoding || 'binary'; encoding = encoding || 'binary';
let buf = new Buffer(4); const buf = Buffer.alloc(4);
buf.writeInt32BE(this.hash & 0xffffffff, 0); buf.writeInt32BE(this.hash & 0xffffffff, 0);
return buf.toString(encoding); return buf.toString(encoding);
} }

View File

@ -26,7 +26,7 @@ const FTN_PACKET_MESSAGE_TYPE = 2;
const FTN_PACKET_BAUD_TYPE_2_2 = 2; const FTN_PACKET_BAUD_TYPE_2_2 = 2;
// SAUCE magic header + version ("00") // SAUCE magic header + version ("00")
const FTN_MESSAGE_SAUCE_HEADER = new Buffer('SAUCE00'); const FTN_MESSAGE_SAUCE_HEADER = Buffer.from('SAUCE00');
const FTN_MESSAGE_KLUDGE_PREFIX = '\x01'; const FTN_MESSAGE_KLUDGE_PREFIX = '\x01';
@ -273,7 +273,7 @@ function Packet(options) {
}; };
this.getPacketHeaderBuffer = function(packetHeader) { this.getPacketHeaderBuffer = function(packetHeader) {
let buffer = new Buffer(FTN_PACKET_HEADER_SIZE); let buffer = Buffer.alloc(FTN_PACKET_HEADER_SIZE);
buffer.writeUInt16LE(packetHeader.origNode, 0); buffer.writeUInt16LE(packetHeader.origNode, 0);
buffer.writeUInt16LE(packetHeader.destNode, 2); buffer.writeUInt16LE(packetHeader.destNode, 2);
@ -311,7 +311,7 @@ function Packet(options) {
}; };
this.writePacketHeader = function(packetHeader, ws) { this.writePacketHeader = function(packetHeader, ws) {
let buffer = new Buffer(FTN_PACKET_HEADER_SIZE); let buffer = Buffer.alloc(FTN_PACKET_HEADER_SIZE);
buffer.writeUInt16LE(packetHeader.origNode, 0); buffer.writeUInt16LE(packetHeader.origNode, 0);
buffer.writeUInt16LE(packetHeader.destNode, 2); buffer.writeUInt16LE(packetHeader.destNode, 2);
@ -447,8 +447,8 @@ function Packet(options) {
// Also according to the spec, the deprecated "CHARSET" value may be used // Also according to the spec, the deprecated "CHARSET" value may be used
// :TODO: Look into CHARSET more - should we bother supporting it? // :TODO: Look into CHARSET more - should we bother supporting it?
// :TODO: See encodingFromHeader() for CHRS/CHARSET support @ https://github.com/Mithgol/node-fidonet-jam // :TODO: See encodingFromHeader() for CHRS/CHARSET support @ https://github.com/Mithgol/node-fidonet-jam
const FTN_CHRS_PREFIX = new Buffer( [ 0x01, 0x43, 0x48, 0x52, 0x53, 0x3a, 0x20 ] ); // "\x01CHRS:" const FTN_CHRS_PREFIX = Buffer.from( [ 0x01, 0x43, 0x48, 0x52, 0x53, 0x3a, 0x20 ] ); // "\x01CHRS:"
const FTN_CHRS_SUFFIX = new Buffer( [ 0x0d ] ); const FTN_CHRS_SUFFIX = Buffer.from( [ 0x0d ] );
let chrsPrefixIndex = messageBodyBuffer.indexOf(FTN_CHRS_PREFIX); let chrsPrefixIndex = messageBodyBuffer.indexOf(FTN_CHRS_PREFIX);
if(chrsPrefixIndex < 0) { if(chrsPrefixIndex < 0) {
@ -724,7 +724,7 @@ function Packet(options) {
buf.writeUInt16LE(message.meta.FtnProperty.ftn_attr_flags, 10); buf.writeUInt16LE(message.meta.FtnProperty.ftn_attr_flags, 10);
buf.writeUInt16LE(message.meta.FtnProperty.ftn_cost, 12); buf.writeUInt16LE(message.meta.FtnProperty.ftn_cost, 12);
const dateTimeBuffer = new Buffer(ftn.getDateTimeString(message.modTimestamp) + '\0'); const dateTimeBuffer = Buffer.from(ftn.getDateTimeString(message.modTimestamp) + '\0');
dateTimeBuffer.copy(buf, 14); dateTimeBuffer.copy(buf, 14);
}; };
@ -747,7 +747,7 @@ function Packet(options) {
async.waterfall( async.waterfall(
[ [
function prepareHeaderAndKludges(callback) { function prepareHeaderAndKludges(callback) {
const basicHeader = new Buffer(34); const basicHeader = Buffer.alloc(34);
self.writeMessageHeader(message, basicHeader); self.writeMessageHeader(message, basicHeader);
// //
@ -864,7 +864,7 @@ function Packet(options) {
}; };
this.writeMessage = function(message, ws, options) { this.writeMessage = function(message, ws, options) {
let basicHeader = new Buffer(34); const basicHeader = Buffer.alloc(34);
self.writeMessageHeader(message, basicHeader); self.writeMessageHeader(message, basicHeader);
ws.write(basicHeader); ws.write(basicHeader);
@ -1054,7 +1054,7 @@ Packet.prototype.writeTerminator = function(ws) {
// From FTS-0001.016: // From FTS-0001.016:
// "A pseudo-message beginning with the word 0000H signifies the end of the packet." // "A pseudo-message beginning with the word 0000H signifies the end of the packet."
// //
ws.write(new Buffer( [ 0x00, 0x00 ] )); // final extra null term ws.write(Buffer.from( [ 0x00, 0x00 ] )); // final extra null term
return 2; return 2;
}; };
@ -1074,7 +1074,7 @@ Packet.prototype.writeStream = function(ws, messages, options) {
}); });
if(true === options.terminatePacket) { if(true === options.terminatePacket) {
ws.write(new Buffer( [ 0 ] )); // final extra null term ws.write(Buffer.from( [ 0 ] )); // final extra null term
} }
}; };

View File

@ -46,7 +46,7 @@ exports.getQuotePrefix = getQuotePrefix;
// See list here: https://github.com/Mithgol/node-fidonet-jam // See list here: https://github.com/Mithgol/node-fidonet-jam
function stringToNullPaddedBuffer(s, bufLen) { function stringToNullPaddedBuffer(s, bufLen) {
let buffer = new Buffer(bufLen).fill(0x00); let buffer = Buffer.alloc(bufLen);
let enc = iconv.encode(s, 'CP437').slice(0, bufLen); let enc = iconv.encode(s, 'CP437').slice(0, bufLen);
for(let i = 0; i < enc.length; ++i) { for(let i = 0; i < enc.length; ++i) {
buffer[i] = enc[i]; buffer[i] = enc[i];

View File

@ -10,10 +10,10 @@ const { Parser } = require('binary-parser');
exports.readSAUCE = readSAUCE; exports.readSAUCE = readSAUCE;
const SAUCE_SIZE = 128; const SAUCE_SIZE = 128;
const SAUCE_ID = new Buffer([0x53, 0x41, 0x55, 0x43, 0x45]); // 'SAUCE' const SAUCE_ID = Buffer.from([0x53, 0x41, 0x55, 0x43, 0x45]); // 'SAUCE'
// :TODO read comments // :TODO read comments
//const COMNT_ID = new Buffer([0x43, 0x4f, 0x4d, 0x4e, 0x54]); // 'COMNT' //const COMNT_ID = Buffer.from([0x43, 0x4f, 0x4d, 0x4e, 0x54]); // 'COMNT'
exports.SAUCE_SIZE = SAUCE_SIZE; exports.SAUCE_SIZE = SAUCE_SIZE;
// :TODO: SAUCE should be a class // :TODO: SAUCE should be a class

View File

@ -159,8 +159,8 @@ const NEW_ENVIRONMENT_COMMANDS = {
USERVAR : 3, USERVAR : 3,
}; };
const IAC_BUF = new Buffer([ COMMANDS.IAC ]); const IAC_BUF = Buffer.from([ COMMANDS.IAC ]);
const IAC_SE_BUF = new Buffer([ COMMANDS.IAC, COMMANDS.SE ]); const IAC_SE_BUF = Buffer.from([ COMMANDS.IAC, COMMANDS.SE ]);
const COMMAND_NAMES = Object.keys(COMMANDS).reduce(function(names, name) { const COMMAND_NAMES = Object.keys(COMMANDS).reduce(function(names, name) {
names[COMMANDS[name]] = name.toLowerCase(); names[COMMANDS[name]] = name.toLowerCase();
@ -766,7 +766,7 @@ TelnetClient.prototype.handleMiscCommand = function(evt) {
}; };
TelnetClient.prototype.requestTerminalType = function() { TelnetClient.prototype.requestTerminalType = function() {
const buf = new Buffer( [ const buf = Buffer.from( [
COMMANDS.IAC, COMMANDS.IAC,
COMMANDS.SB, COMMANDS.SB,
OPTIONS.TERMINAL_TYPE, OPTIONS.TERMINAL_TYPE,
@ -777,10 +777,10 @@ TelnetClient.prototype.requestTerminalType = function() {
}; };
const WANTED_ENVIRONMENT_VAR_BUFS = [ const WANTED_ENVIRONMENT_VAR_BUFS = [
new Buffer( 'LINES' ), Buffer.from( 'LINES' ),
new Buffer( 'COLUMNS' ), Buffer.from( 'COLUMNS' ),
new Buffer( 'TERM' ), Buffer.from( 'TERM' ),
new Buffer( 'TERM_PROGRAM' ) Buffer.from( 'TERM_PROGRAM' )
]; ];
TelnetClient.prototype.requestNewEnvironment = function() { TelnetClient.prototype.requestNewEnvironment = function() {
@ -793,7 +793,7 @@ TelnetClient.prototype.requestNewEnvironment = function() {
const self = this; const self = this;
const bufs = buffers(); const bufs = buffers();
bufs.push(new Buffer( [ bufs.push(Buffer.from( [
COMMANDS.IAC, COMMANDS.IAC,
COMMANDS.SB, COMMANDS.SB,
OPTIONS.NEW_ENVIRONMENT, OPTIONS.NEW_ENVIRONMENT,
@ -801,10 +801,10 @@ TelnetClient.prototype.requestNewEnvironment = function() {
)); ));
for(let i = 0; i < WANTED_ENVIRONMENT_VAR_BUFS.length; ++i) { for(let i = 0; i < WANTED_ENVIRONMENT_VAR_BUFS.length; ++i) {
bufs.push(new Buffer( [ NEW_ENVIRONMENT_COMMANDS.VAR ] ), WANTED_ENVIRONMENT_VAR_BUFS[i] ); bufs.push(Buffer.from( [ NEW_ENVIRONMENT_COMMANDS.VAR ] ), WANTED_ENVIRONMENT_VAR_BUFS[i] );
} }
bufs.push(new Buffer([ NEW_ENVIRONMENT_COMMANDS.USERVAR, COMMANDS.IAC, COMMANDS.SE ])); bufs.push(Buffer.from([ NEW_ENVIRONMENT_COMMANDS.USERVAR, COMMANDS.IAC, COMMANDS.SE ]));
self.output.write(bufs.toBuffer()); self.output.write(bufs.toBuffer());
@ -836,7 +836,7 @@ Object.keys(OPTIONS).forEach(function(name) {
const code = OPTIONS[name]; const code = OPTIONS[name];
Command.prototype[name.toLowerCase()] = function() { Command.prototype[name.toLowerCase()] = function() {
const buf = new Buffer(3); const buf = Buffer.alloc(3);
buf[0] = COMMANDS.IAC; buf[0] = COMMANDS.IAC;
buf[1] = this.command; buf[1] = this.command;
buf[2] = code; buf[2] = code;

View File

@ -33,7 +33,7 @@ exports.moduleInfo = {
author : 'Andrew Pamment', author : 'Andrew Pamment',
}; };
const IAC_DO_TERM_TYPE = new Buffer( [ 255, 253, 24 ] ); const IAC_DO_TERM_TYPE = Buffer.from( [ 255, 253, 24 ] );
class TelnetClientConnection extends EventEmitter { class TelnetClientConnection extends EventEmitter {
constructor(client) { constructor(client) {
@ -103,7 +103,7 @@ class TelnetClientConnection extends EventEmitter {
// //
let bufs = buffers(); let bufs = buffers();
bufs.push(new Buffer( bufs.push(Buffer.from(
[ [
255, // IAC 255, // IAC
250, // SB 250, // SB
@ -113,8 +113,8 @@ class TelnetClientConnection extends EventEmitter {
)); ));
bufs.push( bufs.push(
new Buffer(this.client.term.termType), // e.g. "ansi" Buffer.from(this.client.term.termType), // e.g. "ansi"
new Buffer( [ 255, 240 ] ) // IAC, SE Buffer.from( [ 255, 240 ] ) // IAC, SE
); );
return bufs.toBuffer(); return bufs.toBuffer();

View File

@ -130,8 +130,8 @@ module.exports = class User {
// //
// Use constant time comparison here for security feel-goods // Use constant time comparison here for security feel-goods
// //
const passDkBuf = new Buffer(passDk, 'hex'); const passDkBuf = Buffer.from(passDk, 'hex');
const propsDkBuf = new Buffer(propsDk, 'hex'); const propsDkBuf = Buffer.from(propsDk, 'hex');
if(passDkBuf.length !== propsDkBuf.length) { if(passDkBuf.length !== propsDkBuf.length) {
return callback(Errors.AccessDenied('Invalid password')); return callback(Errors.AccessDenied('Invalid password'));
@ -595,7 +595,7 @@ module.exports = class User {
} }
static generatePasswordDerivedKey(password, salt, cb) { static generatePasswordDerivedKey(password, salt, cb) {
password = new Buffer(password).toString('hex'); password = Buffer.from(password).toString('hex');
crypto.pbkdf2(password, salt, User.PBKDF2.iterations, User.PBKDF2.keyLen, 'sha1', (err, dk) => { crypto.pbkdf2(password, salt, User.PBKDF2.iterations, User.PBKDF2.keyLen, 'sha1', (err, dk) => {
if(err) { if(err) {

View File

@ -11,17 +11,17 @@ function createNamedUUID(namespaceUuid, key) {
// https://github.com/download13/uuidv5/blob/master/uuid.js // https://github.com/download13/uuidv5/blob/master/uuid.js
// //
if(!Buffer.isBuffer(namespaceUuid)) { if(!Buffer.isBuffer(namespaceUuid)) {
namespaceUuid = new Buffer(namespaceUuid); namespaceUuid = Buffer.from(namespaceUuid);
} }
if(!Buffer.isBuffer(key)) { if(!Buffer.isBuffer(key)) {
key = new Buffer(key); key = Buffer.from(key);
} }
let digest = createHash('sha1').update( let digest = createHash('sha1').update(
Buffer.concat( [ namespaceUuid, key ] )).digest(); Buffer.concat( [ namespaceUuid, key ] )).digest();
let u = new Buffer(16); let u = Buffer.alloc(16);
// bbbb - bb - bb - bb - bbbbbb // bbbb - bb - bb - bb - bbbbbb
digest.copy(u, 0, 0, 4); // time_low digest.copy(u, 0, 0, 4); // time_low

View File

@ -2,7 +2,7 @@
{ # this ensures the entire script is downloaded before execution { # this ensures the entire script is downloaded before execution
ENIGMA_NODE_VERSION=${ENIGMA_NODE_VERSION:=8} ENIGMA_NODE_VERSION=${ENIGMA_NODE_VERSION:=10}
ENIGMA_INSTALL_DIR=${ENIGMA_INSTALL_DIR:=$HOME/enigma-bbs} ENIGMA_INSTALL_DIR=${ENIGMA_INSTALL_DIR:=$HOME/enigma-bbs}
ENIGMA_SOURCE=${ENIGMA_SOURCE:=https://github.com/NuSkooler/enigma-bbs.git} ENIGMA_SOURCE=${ENIGMA_SOURCE:=https://github.com/NuSkooler/enigma-bbs.git}
TIME_FORMAT=`date "+%Y-%m-%d %H:%M:%S"` TIME_FORMAT=`date "+%Y-%m-%d %H:%M:%S"`

2663
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@
"dependencies": { "dependencies": {
"async": "^2.5.0", "async": "^2.5.0",
"binary-parser": "^1.3.2", "binary-parser": "^1.3.2",
"buffers": "NuSkooler/node-buffers", "buffers": "github:NuSkooler/node-buffers",
"bunyan": "^1.8.12", "bunyan": "^1.8.12",
"exiftool": "^0.0.3", "exiftool": "^0.0.3",
"fs-extra": "^5.0.0", "fs-extra": "^5.0.0",
@ -39,12 +39,12 @@
"mime-types": "^2.1.17", "mime-types": "^2.1.17",
"minimist": "1.2.x", "minimist": "1.2.x",
"moment": "^2.20.1", "moment": "^2.20.1",
"nodemailer": "^4.4.1",
"node-pty": "^0.7.4", "node-pty": "^0.7.4",
"nodemailer": "^4.4.1",
"rlogin": "^1.0.0", "rlogin": "^1.0.0",
"sane": "^2.2.0", "sane": "^2.2.0",
"sanitize-filename": "^1.6.1", "sanitize-filename": "^1.6.1",
"sqlite3": "^3.1.9", "sqlite3": "^4.0.0",
"sqlite3-trans": "^1.2.0", "sqlite3-trans": "^1.2.0",
"ssh2": "^0.5.5", "ssh2": "^0.5.5",
"temptmp": "^1.0.0", "temptmp": "^1.0.0",
@ -56,6 +56,6 @@
}, },
"devDependencies": {}, "devDependencies": {},
"engines": { "engines": {
"node": ">=6.9.2" "node": ">=8"
} }
} }