From 9e9dc9af898b4df8c42e1b77ccb3169a33e2b393 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Mon, 15 Jun 2020 19:08:55 -0600 Subject: [PATCH] A lot of code tidy up --- core/achievement.js | 2 +- core/client.js | 2 +- core/cp437util.js | 78 ++++++++++++------------ core/mbf.js | 64 ++++++++++---------- core/message.js | 2 +- core/message_base_qwk_export.js | 2 +- core/mrc.js | 2 +- core/msg_area_post_fse.js | 3 +- core/oputil/oputil_message_base.js | 6 +- core/oputil/oputil_user.js | 3 +- core/qwk_mail_packet.js | 90 ++++++++++++++-------------- core/servers/chat/mrc_multiplexer.js | 2 +- core/servers/login/telnet.js | 5 +- core/servers/login/websocket.js | 1 - core/string_util.js | 20 +++---- core/telnet_bridge.js | 2 +- 16 files changed, 144 insertions(+), 140 deletions(-) diff --git a/core/achievement.js b/core/achievement.js index 20e32603..d40acc18 100644 --- a/core/achievement.js +++ b/core/achievement.js @@ -382,7 +382,7 @@ class Achievements { // ^---- we met here // ^------------^ retroactive range // - async.eachSeries(achievement.matchKeys.slice(index), (k, nextKey) => { + async.eachSeries(achievement.matchKeys.slice(index), (k, nextKey) => { const [ det, fld, val ] = achievement.getMatchDetails(k); if(!det) { return nextKey(null); diff --git a/core/client.js b/core/client.js index 88c9ea0f..b8b08c34 100644 --- a/core/client.js +++ b/core/client.js @@ -493,7 +493,7 @@ Client.prototype.stopIdleMonitor = function() { Client.prototype.explicitActivityTimeUpdate = function() { this.lastActivityTime = Date.now(); -} +}; Client.prototype.overrideIdleLogoutSeconds = function(seconds) { this.idleLogoutSecondsOverride = seconds; diff --git a/core/cp437util.js b/core/cp437util.js index 32425d3a..9e0b2033 100644 --- a/core/cp437util.js +++ b/core/cp437util.js @@ -2,54 +2,54 @@ const CP437UnicodeTable = [ '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', - '\u0007', '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', - '\u000E', '\u000F', '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', - '\u0015', '\u0016', '\u0017', '\u0018', '\u0019', '\u001A', '\u001B', - '\u001C', '\u001D', '\u001E', '\u001F', '\u0020', '\u0021', '\u0022', - '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', '\u0028', '\u0029', - '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', '\u0030', - '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', - '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', - '\u003F', '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', - '\u0046', '\u0047', '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', - '\u004D', '\u004E', '\u004F', '\u0050', '\u0051', '\u0052', '\u0053', - '\u0054', '\u0055', '\u0056', '\u0057', '\u0058', '\u0059', '\u005A', - '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', '\u0060', '\u0061', - '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', '\u0068', - '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', - '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', - '\u0077', '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', - '\u007E', '\u007F', '\u00C7', '\u00FC', '\u00E9', '\u00E2', '\u00E4', - '\u00E0', '\u00E5', '\u00E7', '\u00EA', '\u00EB', '\u00E8', '\u00EF', - '\u00EE', '\u00EC', '\u00C4', '\u00C5', '\u00C9', '\u00E6', '\u00C6', - '\u00F4', '\u00F6', '\u00F2', '\u00FB', '\u00F9', '\u00FF', '\u00D6', - '\u00DC', '\u00A2', '\u00A3', '\u00A5', '\u20A7', '\u0192', '\u00E1', - '\u00ED', '\u00F3', '\u00FA', '\u00F1', '\u00D1', '\u00AA', '\u00BA', - '\u00BF', '\u2310', '\u00AC', '\u00BD', '\u00BC', '\u00A1', '\u00AB', - '\u00BB', '\u2591', '\u2592', '\u2593', '\u2502', '\u2524', '\u2561', - '\u2562', '\u2556', '\u2555', '\u2563', '\u2551', '\u2557', '\u255D', - '\u255C', '\u255B', '\u2510', '\u2514', '\u2534', '\u252C', '\u251C', - '\u2500', '\u253C', '\u255E', '\u255F', '\u255A', '\u2554', '\u2569', - '\u2566', '\u2560', '\u2550', '\u256C', '\u2567', '\u2568', '\u2564', - '\u2565', '\u2559', '\u2558', '\u2552', '\u2553', '\u256B', '\u256A', - '\u2518', '\u250C', '\u2588', '\u2584', '\u258C', '\u2590', '\u2580', - '\u03B1', '\u00DF', '\u0393', '\u03C0', '\u03A3', '\u03C3', '\u00B5', - '\u03C4', '\u03A6', '\u0398', '\u03A9', '\u03B4', '\u221E', '\u03C6', - '\u03B5', '\u2229', '\u2261', '\u00B1', '\u2265', '\u2264', '\u2320', - '\u2321', '\u00F7', '\u2248', '\u00B0', '\u2219', '\u00B7', '\u221A', - '\u207F', '\u00B2', '\u25A0', '\u00A0' + '\u0007', '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', + '\u000E', '\u000F', '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', + '\u0015', '\u0016', '\u0017', '\u0018', '\u0019', '\u001A', '\u001B', + '\u001C', '\u001D', '\u001E', '\u001F', '\u0020', '\u0021', '\u0022', + '\u0023', '\u0024', '\u0025', '\u0026', '\u0027', '\u0028', '\u0029', + '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F', '\u0030', + '\u0031', '\u0032', '\u0033', '\u0034', '\u0035', '\u0036', '\u0037', + '\u0038', '\u0039', '\u003A', '\u003B', '\u003C', '\u003D', '\u003E', + '\u003F', '\u0040', '\u0041', '\u0042', '\u0043', '\u0044', '\u0045', + '\u0046', '\u0047', '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', + '\u004D', '\u004E', '\u004F', '\u0050', '\u0051', '\u0052', '\u0053', + '\u0054', '\u0055', '\u0056', '\u0057', '\u0058', '\u0059', '\u005A', + '\u005B', '\u005C', '\u005D', '\u005E', '\u005F', '\u0060', '\u0061', + '\u0062', '\u0063', '\u0064', '\u0065', '\u0066', '\u0067', '\u0068', + '\u0069', '\u006A', '\u006B', '\u006C', '\u006D', '\u006E', '\u006F', + '\u0070', '\u0071', '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', + '\u0077', '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D', + '\u007E', '\u007F', '\u00C7', '\u00FC', '\u00E9', '\u00E2', '\u00E4', + '\u00E0', '\u00E5', '\u00E7', '\u00EA', '\u00EB', '\u00E8', '\u00EF', + '\u00EE', '\u00EC', '\u00C4', '\u00C5', '\u00C9', '\u00E6', '\u00C6', + '\u00F4', '\u00F6', '\u00F2', '\u00FB', '\u00F9', '\u00FF', '\u00D6', + '\u00DC', '\u00A2', '\u00A3', '\u00A5', '\u20A7', '\u0192', '\u00E1', + '\u00ED', '\u00F3', '\u00FA', '\u00F1', '\u00D1', '\u00AA', '\u00BA', + '\u00BF', '\u2310', '\u00AC', '\u00BD', '\u00BC', '\u00A1', '\u00AB', + '\u00BB', '\u2591', '\u2592', '\u2593', '\u2502', '\u2524', '\u2561', + '\u2562', '\u2556', '\u2555', '\u2563', '\u2551', '\u2557', '\u255D', + '\u255C', '\u255B', '\u2510', '\u2514', '\u2534', '\u252C', '\u251C', + '\u2500', '\u253C', '\u255E', '\u255F', '\u255A', '\u2554', '\u2569', + '\u2566', '\u2560', '\u2550', '\u256C', '\u2567', '\u2568', '\u2564', + '\u2565', '\u2559', '\u2558', '\u2552', '\u2553', '\u256B', '\u256A', + '\u2518', '\u250C', '\u2588', '\u2584', '\u258C', '\u2590', '\u2580', + '\u03B1', '\u00DF', '\u0393', '\u03C0', '\u03A3', '\u03C3', '\u00B5', + '\u03C4', '\u03A6', '\u0398', '\u03A9', '\u03B4', '\u221E', '\u03C6', + '\u03B5', '\u2229', '\u2261', '\u00B1', '\u2265', '\u2264', '\u2320', + '\u2321', '\u00F7', '\u2248', '\u00B0', '\u2219', '\u00B7', '\u221A', + '\u207F', '\u00B2', '\u25A0', '\u00A0' ]; -const NonCP437EncodableRegExp = /[^\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F\u0020\u0021\u0022\u0023\u0024\u0025\u0026\u0027\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005A\u005B\u005C\u005D\u005E\u005F\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00A2\u00A3\u00A5\u20A7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0]/; +const NonCP437EncodableRegExp = /[^\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000A\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F\u0020\u0021\u0022\u0023\u0024\u0025\u0026\u0027\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005A\u005B\u005C\u005D\u005E\u005F\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9\u00FF\u00D6\u00DC\u00A2\u00A3\u00A5\u20A7\u0192\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0]/; // eslint-disable-line no-control-regex const isCP437Encodable = (s) => { if (!s.length) { return true; } return !NonCP437EncodableRegExp.test(s); -} +}; module.exports = { CP437UnicodeTable, isCP437Encodable, -} \ No newline at end of file +}; diff --git a/core/mbf.js b/core/mbf.js index 9c3b2f6d..b051033c 100644 --- a/core/mbf.js +++ b/core/mbf.js @@ -9,51 +9,51 @@ const { Errors } = require('./enig_error'); // // Number to 32bit MBF -numToMbf32 = (v) => { +const numToMbf32 = (v) => { const mbf = Buffer.alloc(4); - if (0 === v) { - return mbf; - } + if (0 === v) { + return mbf; + } - const ieee = Buffer.alloc(4); - ieee.writeFloatLE(v, 0); + const ieee = Buffer.alloc(4); + ieee.writeFloatLE(v, 0); - const sign = ieee[3] & 0x80; - let exp = (ieee[3] << 1) | (ieee[2] >> 7); + const sign = ieee[3] & 0x80; + let exp = (ieee[3] << 1) | (ieee[2] >> 7); if (exp === 0xfe) { - throw Errors.Invalid(`${v} cannot be converted to mbf`); - } + throw Errors.Invalid(`${v} cannot be converted to mbf`); + } - exp += 2; + exp += 2; mbf[3] = exp; - mbf[2] = sign | (ieee[2] & 0x7f); - mbf[1] = ieee[1]; - mbf[0] = ieee[0]; + mbf[2] = sign | (ieee[2] & 0x7f); + mbf[1] = ieee[1]; + mbf[0] = ieee[0]; - return mbf; -} + return mbf; +}; -mbf32ToNum = (mbf) => { - if (0 === mbf[3]) { - return 0.0; - } +const mbf32ToNum = (mbf) => { + if (0 === mbf[3]) { + return 0.0; + } - const ieee = Buffer.alloc(4); - const sign = mbf[2] & 0x80; - const exp = mbf[3] - 2; + const ieee = Buffer.alloc(4); + const sign = mbf[2] & 0x80; + const exp = mbf[3] - 2; - ieee[3] = sign | (exp >> 1); - ieee[2] = (exp << 7) | (mbf[2] & 0x7f); - ieee[1] = mbf[1]; - ieee[0] = mbf[0]; + ieee[3] = sign | (exp >> 1); + ieee[2] = (exp << 7) | (mbf[2] & 0x7f); + ieee[1] = mbf[1]; + ieee[0] = mbf[0]; - return ieee.readFloatLE(0); -} + return ieee.readFloatLE(0); +}; module.exports = { - numToMbf32, - mbf32ToNum, -} \ No newline at end of file + numToMbf32, + mbf32ToNum, +}; diff --git a/core/message.js b/core/message.js index b45e868c..9b7a980e 100644 --- a/core/message.js +++ b/core/message.js @@ -887,7 +887,7 @@ module.exports = class Message { } else { const QUOTE_RE = /^ ((?:[A-Za-z0-9]{2}> )+(?:[A-Za-z0-9]{2}>)*) */; const quoted = []; - const input = _.trimEnd(this.message).replace(/\x08/g, ''); + const input = _.trimEnd(this.message).replace(/\x08/g, ''); // eslint-disable-line no-control-regex // find *last* tearline let tearLinePos = this.getTearLinePosition(input); diff --git a/core/message_base_qwk_export.js b/core/message_base_qwk_export.js index 2f89c1bd..2a86bda7 100644 --- a/core/message_base_qwk_export.js +++ b/core/message_base_qwk_export.js @@ -365,7 +365,7 @@ exports.getModule = class MessageBaseQWKExport extends MenuModule { const sysDownloadPath = paths.join(sysTempDownloadDir, this.tempName); fse.move(packetInfo.path, sysDownloadPath, err => { - return callback(null, sysDownloadPath, packetInfo); + return callback(err, sysDownloadPath, packetInfo); }); }, (sysDownloadPath, packetInfo, callback) => { diff --git a/core/mrc.js b/core/mrc.js index 754e2728..1e0791dd 100644 --- a/core/mrc.js +++ b/core/mrc.js @@ -400,7 +400,7 @@ exports.getModule = class mrcModule extends MenuModule { // normal message formattedMessage = stringFormat(messageFormat, textFormatObj); } else { - // pm + // pm formattedMessage = stringFormat(privateMessageFormat, textFormatObj); } diff --git a/core/msg_area_post_fse.js b/core/msg_area_post_fse.js index 0c92bbfb..5f25fa19 100644 --- a/core/msg_area_post_fse.js +++ b/core/msg_area_post_fse.js @@ -8,7 +8,6 @@ const { hasMessageConfAndAreaWrite, } = require('./message_area.js'); -const _ = require('lodash'); const async = require('async'); exports.moduleInfo = { @@ -77,7 +76,7 @@ exports.getModule = class AreaPostFSEModule extends FullScreenEditorModule { return this.gotoMenuOrShowMessage( noAcsMenu, - 'You do not have the proper access to post here!', + 'You do not have the proper access to post here!' ); } diff --git a/core/oputil/oputil_message_base.js b/core/oputil/oputil_message_base.js index 1790b1e5..f01f8f9c 100644 --- a/core/oputil/oputil_message_base.js +++ b/core/oputil/oputil_message_base.js @@ -480,9 +480,11 @@ function dumpQWKPacket() { } ], err => { - + if (err) { + console.error(`QWK dump failed: ${err.message}`); + } } - ) + ); } function exportQWKPacket() { diff --git a/core/oputil/oputil_user.js b/core/oputil/oputil_user.js index 07f9227a..e3501d13 100644 --- a/core/oputil/oputil_user.js +++ b/core/oputil/oputil_user.js @@ -507,9 +507,10 @@ function listUsers() { }, (userList, callback) => { userList.forEach(user => { - console.info(`${user.userId}: ${user.userName}`); }); + + return callback(null); }, ], err => { diff --git a/core/qwk_mail_packet.js b/core/qwk_mail_packet.js index de42abf8..6bdfe8ad 100644 --- a/core/qwk_mail_packet.js +++ b/core/qwk_mail_packet.js @@ -178,7 +178,7 @@ const replaceCharInBuffer = (buffer, search, replace) => { buffer[i] = replace; ++i; } -} +}; class QWKPacketReader extends EventEmitter { constructor( @@ -269,7 +269,7 @@ class QWKPacketReader extends EventEmitter { case 'ID.MSG' : if (this.options.mode === QWKPacketReader.Modes.Guess) { - this.options.mode = Modes.REP; + this.options.mode = QWKPacketReader.Modes.REP; } if (this.options.mode === QWKPacketReader.Modes.REP) { @@ -374,7 +374,7 @@ class QWKPacketReader extends EventEmitter { err => { return cb(err); } - ) + ); } readControl(cb) { @@ -458,7 +458,7 @@ class QWKPacketReader extends EventEmitter { } } - return cb(null); + return cb(null); }); } @@ -576,41 +576,43 @@ class QWKPacketReader extends EventEmitter { } else { switch (state) { case 'header' : - const header = MessageHeaderParser.parse(buffer); - encoding = encodingToSpec; // reset per message + { + const header = MessageHeaderParser.parse(buffer); + encoding = encodingToSpec; // reset per message - // massage into something a little more sane (things we can't quite do in the parser directly) - ['toName', 'fromName', 'subject'].forEach(field => { - // note: always use to-spec encoding here - header[field] = iconv.decode(header[field], encodingToSpec).trim(); - }); + // massage into something a little more sane (things we can't quite do in the parser directly) + ['toName', 'fromName', 'subject'].forEach(field => { + // note: always use to-spec encoding here + header[field] = iconv.decode(header[field], encodingToSpec).trim(); + }); - header.timestamp = moment(header.timestamp, QWKHeaderTimestampFormat); + header.timestamp = moment(header.timestamp, QWKHeaderTimestampFormat); - currMessage = { - header, - // these may be overridden - toName : header.toName, - fromName : header.fromName, - subject : header.subject, - }; + currMessage = { + header, + // these may be overridden + toName : header.toName, + fromName : header.fromName, + subject : header.subject, + }; - if (_.has(this.packetInfo, 'headers.ini')) { - // Sections for a message in HEADERS.DAT are by current byte offset. - // 128 = first message header = 0x80 = section [80] - const headersSectionId = (blockCount * QWKMessageBlockSize).toString(16); - currMessage.headersExtension = this.packetInfo.headers.ini[headersSectionId]; + if (_.has(this.packetInfo, 'headers.ini')) { + // Sections for a message in HEADERS.DAT are by current byte offset. + // 128 = first message header = 0x80 = section [80] + const headersSectionId = (blockCount * QWKMessageBlockSize).toString(16); + currMessage.headersExtension = this.packetInfo.headers.ini[headersSectionId]; + } + + // if we have HEADERS.DAT with a 'Utf8' override for this message, + // the overridden to/from/subject/message fields are UTF-8 + if (currMessage.headersExtension && 'true' === currMessage.headersExtension.Utf8.toLowerCase()) { + encoding = 'utf8'; + } + + // remainder of blocks until the end of this message + messageBlocksRemain = header.numBlocks - 1; + state = 'message'; } - - // if we have HEADERS.DAT with a 'Utf8' override for this message, - // the overridden to/from/subject/message fields are UTF-8 - if (currMessage.headersExtension && 'true' === currMessage.headersExtension.Utf8.toLowerCase()) { - encoding = 'utf8'; - } - - // remainder of blocks until the end of this message - messageBlocksRemain = header.numBlocks - 1; - state = 'message'; break; case 'message' : @@ -819,7 +821,7 @@ class QWKPacketReader extends EventEmitter { readNextBlock(); }); } -}; +} class QWKPacketWriter extends EventEmitter { constructor( @@ -921,7 +923,7 @@ class QWKPacketWriter extends EventEmitter { // we can go up to 65535 for some things, but NDX files are limited to 9999 if (confNumber === 10000) { // sanity... - this.emit('warning', Errors.General(`To many conferences`)); + this.emit('warning', Errors.General('To many conferences (over 9999)')); } else { this.areaTagConfMap[areaTag] = confNumber; ++confNumber; @@ -959,7 +961,7 @@ class QWKPacketWriter extends EventEmitter { this.emit('ready'); } - ) + ); } makeMessageIdentifier(message) { @@ -1010,7 +1012,7 @@ class QWKPacketWriter extends EventEmitter { if (message.meta.QwkKludge) { for (let [kludge, value] of Object.entries(message.meta.QwkKludge)) { fullMessageBody += `${kludge}: ${value}\n`; - }; + } } } else { fullMessageBody += `@MSGID: ${this.makeMessageIdentifier(message)}\n`; @@ -1117,7 +1119,7 @@ class QWKPacketWriter extends EventEmitter { } else { this.cachedCompareNames = []; } - }; + } return this.cachedCompareNames.includes(message.toUserName.toLowerCase()); } @@ -1183,7 +1185,7 @@ class QWKPacketWriter extends EventEmitter { this.emit('finished'); } - ) + ); } _getNextAvailPacketFileName(packetDirectory, cb) { @@ -1201,13 +1203,13 @@ class QWKPacketWriter extends EventEmitter { } else if (digits < 100) { ext = `Q${digits}`; } else { - return callback(Errors.UnexpectedState(`Unable to choose a valid QWK output filename`)); + return callback(Errors.UnexpectedState('Unable to choose a valid QWK output filename')); } ++digits; const filename = `${this.options.bbsID}.${ext}`; - fs.stat(paths.join(packetDirectory, filename), (err, stats) => { + fs.stat(paths.join(packetDirectory, filename), err => { if (err && 'ENOENT' === err.code) { return callback(null, filename); } else { @@ -1242,7 +1244,7 @@ class QWKPacketWriter extends EventEmitter { packetPath, files, this.workDir, - err => { + () => { fs.stat(packetPath, (err, stats) => { if (stats) { this.emit('packet', { stats, path : packetPath } ); @@ -1535,4 +1537,4 @@ class QWKPacketWriter extends EventEmitter { module.exports = { QWKPacketReader, QWKPacketWriter, -} +}; diff --git a/core/servers/chat/mrc_multiplexer.js b/core/servers/chat/mrc_multiplexer.js index 34991de7..306e73c8 100644 --- a/core/servers/chat/mrc_multiplexer.js +++ b/core/servers/chat/mrc_multiplexer.js @@ -17,7 +17,7 @@ const os = require('os'); // MRC const protocolVersion = '1.2.9'; -const lineDelimiter = new RegExp('\r\n|\r|\n'); +const lineDelimiter = new RegExp('\r\n|\r|\n'); // eslint-disable-line no-control-regex const ModuleInfo = exports.moduleInfo = { name : 'MRC', diff --git a/core/servers/login/telnet.js b/core/servers/login/telnet.js index 240ce06b..12a3ed36 100644 --- a/core/servers/login/telnet.js +++ b/core/servers/login/telnet.js @@ -3,6 +3,7 @@ const LoginServerModule = require('../../login_server_module'); const { Client } = require('../../client'); const Config = require('../../config').get; const { log: Log } = require('../../logger'); +const { Errors } = require('../../enig_error'); // deps const net = require('net'); @@ -173,7 +174,7 @@ class TelnetClient { return this.disconnect(); }); - this.socket.on('AYT', () => { + this.socket.on('AYT', command => { this.socket.write('\b'); return this._logTrace(command, 'Are You There (AYT) - Replied'); }); @@ -230,7 +231,7 @@ class TelnetClient { this.clientReadyHandled = true; this.emit('ready', { firstMenu : Config().loginServers.telnet.firstMenu } ); } -}; +} inherits(TelnetClient, Client); diff --git a/core/servers/login/websocket.js b/core/servers/login/websocket.js index 42a22723..ce89c547 100644 --- a/core/servers/login/websocket.js +++ b/core/servers/login/websocket.js @@ -14,7 +14,6 @@ const WebSocketServer = require('ws').Server; const http = require('http'); const https = require('https'); const fs = require('graceful-fs'); -const Writable = require('stream'); const { Duplex } = require('stream'); const forEachSeries = require('async/forEachSeries'); diff --git a/core/string_util.js b/core/string_util.js index 2f6596c8..6887275e 100644 --- a/core/string_util.js +++ b/core/string_util.js @@ -185,7 +185,7 @@ function replaceAt(s, n, t) { } const RE_NON_PRINTABLE = - /[\0-\x1F\x7F-\x9F\xAD\u0378\u0379\u037F-\u0383\u038B\u038D\u03A2\u0528-\u0530\u0557\u0558\u0560\u0588\u058B-\u058E\u0590\u05C8-\u05CF\u05EB-\u05EF\u05F5-\u0605\u061C\u061D\u06DD\u070E\u070F\u074B\u074C\u07B2-\u07BF\u07FB-\u07FF\u082E\u082F\u083F\u085C\u085D\u085F-\u089F\u08A1\u08AD-\u08E3\u08FF\u0978\u0980\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09FC-\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF2-\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B55\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B78-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BFB-\u0C00\u0C04\u0C0D\u0C11\u0C29\u0C34\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5A-\u0C5F\u0C64\u0C65\u0C70-\u0C77\u0C80\u0C81\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0D01\u0D04\u0D0D\u0D11\u0D3B\u0D3C\u0D45\u0D49\u0D4F-\u0D56\u0D58-\u0D5F\u0D64\u0D65\u0D76-\u0D78\u0D80\u0D81\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DF1\u0DF5-\u0E00\u0E3B-\u0E3E\u0E5C-\u0E80\u0E83\u0E85\u0E86\u0E89\u0E8B\u0E8C\u0E8E-\u0E93\u0E98\u0EA0\u0EA4\u0EA6\u0EA8\u0EA9\u0EAC\u0EBA\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F48\u0F6D-\u0F70\u0F98\u0FBD\u0FCD\u0FDB-\u0FFF\u10C6\u10C8-\u10CC\u10CE\u10CF\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u137D-\u137F\u139A-\u139F\u13F5-\u13FF\u169D-\u169F\u16F1-\u16FF\u170D\u1715-\u171F\u1737-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17DE\u17DF\u17EA-\u17EF\u17FA-\u17FF\u180F\u181A-\u181F\u1878-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191D-\u191F\u192C-\u192F\u193C-\u193F\u1941-\u1943\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DB-\u19DD\u1A1C\u1A1D\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1A9F\u1AAE-\u1AFF\u1B4C-\u1B4F\u1B7D-\u1B7F\u1BF4-\u1BFB\u1C38-\u1C3A\u1C4A-\u1C4C\u1C80-\u1CBF\u1CC8-\u1CCF\u1CF7-\u1CFF\u1DE7-\u1DFB\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FC5\u1FD4\u1FD5\u1FDC\u1FF0\u1FF1\u1FF5\u1FFF\u200B-\u200F\u202A-\u202E\u2060-\u206F\u2072\u2073\u208F\u209D-\u209F\u20BB-\u20CF\u20F1-\u20FF\u218A-\u218F\u23F4-\u23FF\u2427-\u243F\u244B-\u245F\u2700\u2B4D-\u2B4F\u2B5A-\u2BFF\u2C2F\u2C5F\u2CF4-\u2CF8\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D71-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E3C-\u2E7F\u2E9A\u2EF4-\u2EFF\u2FD6-\u2FEF\u2FFC-\u2FFF\u3040\u3097\u3098\u3100-\u3104\u312E-\u3130\u318F\u31BB-\u31BF\u31E4-\u31EF\u321F\u32FF\u4DB6-\u4DBF\u9FCD-\u9FFF\uA48D-\uA48F\uA4C7-\uA4CF\uA62C-\uA63F\uA698-\uA69E\uA6F8-\uA6FF\uA78F\uA794-\uA79F\uA7AB-\uA7F7\uA82C-\uA82F\uA83A-\uA83F\uA878-\uA87F\uA8C5-\uA8CD\uA8DA-\uA8DF\uA8FC-\uA8FF\uA954-\uA95E\uA97D-\uA97F\uA9CE\uA9DA-\uA9DD\uA9E0-\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A\uAA5B\uAA7C-\uAA7F\uAAC3-\uAADA\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F-\uABBF\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBC2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFE\uFDFF\uFE1A-\uFE1F\uFE27-\uFE2F\uFE53\uFE67\uFE6C-\uFE6F\uFE75\uFEFD-\uFF00\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFDF\uFFE7\uFFEF-\uFFFB\uFFFE\uFFFF]/; // eslint-disable-line no-control-regex + /[\0-\x1F\x7F-\x9F\xAD\u0378\u0379\u037F-\u0383\u038B\u038D\u03A2\u0528-\u0530\u0557\u0558\u0560\u0588\u058B-\u058E\u0590\u05C8-\u05CF\u05EB-\u05EF\u05F5-\u0605\u061C\u061D\u06DD\u070E\u070F\u074B\u074C\u07B2-\u07BF\u07FB-\u07FF\u082E\u082F\u083F\u085C\u085D\u085F-\u089F\u08A1\u08AD-\u08E3\u08FF\u0978\u0980\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09FC-\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF2-\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B55\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B78-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BFB-\u0C00\u0C04\u0C0D\u0C11\u0C29\u0C34\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5A-\u0C5F\u0C64\u0C65\u0C70-\u0C77\u0C80\u0C81\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0D01\u0D04\u0D0D\u0D11\u0D3B\u0D3C\u0D45\u0D49\u0D4F-\u0D56\u0D58-\u0D5F\u0D64\u0D65\u0D76-\u0D78\u0D80\u0D81\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DF1\u0DF5-\u0E00\u0E3B-\u0E3E\u0E5C-\u0E80\u0E83\u0E85\u0E86\u0E89\u0E8B\u0E8C\u0E8E-\u0E93\u0E98\u0EA0\u0EA4\u0EA6\u0EA8\u0EA9\u0EAC\u0EBA\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F48\u0F6D-\u0F70\u0F98\u0FBD\u0FCD\u0FDB-\u0FFF\u10C6\u10C8-\u10CC\u10CE\u10CF\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u137D-\u137F\u139A-\u139F\u13F5-\u13FF\u169D-\u169F\u16F1-\u16FF\u170D\u1715-\u171F\u1737-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17DE\u17DF\u17EA-\u17EF\u17FA-\u17FF\u180F\u181A-\u181F\u1878-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191D-\u191F\u192C-\u192F\u193C-\u193F\u1941-\u1943\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DB-\u19DD\u1A1C\u1A1D\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1A9F\u1AAE-\u1AFF\u1B4C-\u1B4F\u1B7D-\u1B7F\u1BF4-\u1BFB\u1C38-\u1C3A\u1C4A-\u1C4C\u1C80-\u1CBF\u1CC8-\u1CCF\u1CF7-\u1CFF\u1DE7-\u1DFB\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FC5\u1FD4\u1FD5\u1FDC\u1FF0\u1FF1\u1FF5\u1FFF\u200B-\u200F\u202A-\u202E\u2060-\u206F\u2072\u2073\u208F\u209D-\u209F\u20BB-\u20CF\u20F1-\u20FF\u218A-\u218F\u23F4-\u23FF\u2427-\u243F\u244B-\u245F\u2700\u2B4D-\u2B4F\u2B5A-\u2BFF\u2C2F\u2C5F\u2CF4-\u2CF8\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D71-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E3C-\u2E7F\u2E9A\u2EF4-\u2EFF\u2FD6-\u2FEF\u2FFC-\u2FFF\u3040\u3097\u3098\u3100-\u3104\u312E-\u3130\u318F\u31BB-\u31BF\u31E4-\u31EF\u321F\u32FF\u4DB6-\u4DBF\u9FCD-\u9FFF\uA48D-\uA48F\uA4C7-\uA4CF\uA62C-\uA63F\uA698-\uA69E\uA6F8-\uA6FF\uA78F\uA794-\uA79F\uA7AB-\uA7F7\uA82C-\uA82F\uA83A-\uA83F\uA878-\uA87F\uA8C5-\uA8CD\uA8DA-\uA8DF\uA8FC-\uA8FF\uA954-\uA95E\uA97D-\uA97F\uA9CE\uA9DA-\uA9DD\uA9E0-\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A\uAA5B\uAA7C-\uAA7F\uAAC3-\uAADA\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F-\uABBF\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBC2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFE\uFDFF\uFE1A-\uFE1F\uFE27-\uFE2F\uFE53\uFE67\uFE6C-\uFE6F\uFE75\uFEFD-\uFF00\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFDF\uFFE7\uFFEF-\uFFFB\uFFFE\uFFFF]/; // eslint-disable-line no-control-regex, no-misleading-character-class function isPrintable(s) { // @@ -198,18 +198,18 @@ function isPrintable(s) { return !RE_NON_PRINTABLE.test(s); } -const NonLatinCodePointsRegExp = /[^\u0000-\u00ff]/; +const NonLatinCodePointsRegExp = /[^\u0000-\u00ff]/; // eslint-disable-line no-control-regex function containsNonLatinCodepoints(s) { if (!s.length) { - return false; - } + return false; + } - if (s.charCodeAt(0) > 255) { - return true; - } + if (s.charCodeAt(0) > 255) { + return true; + } - return NonLatinCodepointsRegEx.test(s); + return NonLatinCodePointsRegExp.test(s); } function stripAllLineFeeds(s) { @@ -477,6 +477,6 @@ function splitTextAtTerms(s) { } function wildcardMatch(input, rule) { - const escapeRegex = (s) => s.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); - return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$").test(input); + const escapeRegex = (s) => s.replace(/([.*+?^=!:${}()|[]\/\\])/g, '\\$1'); + return new RegExp('^' + rule.split('*').map(escapeRegex).join('.*') + '$').test(input); } \ No newline at end of file diff --git a/core/telnet_bridge.js b/core/telnet_bridge.js index 5c43ced6..0c17715f 100644 --- a/core/telnet_bridge.js +++ b/core/telnet_bridge.js @@ -44,7 +44,7 @@ exports.moduleInfo = { const IAC_DO_TERM_TYPE = TelnetSocket.commandBuffer( Commands.DO, - Options.TTYPE, + Options.TTYPE ); class TelnetClientConnection extends EventEmitter {