From 40799df33893bde825d6faf7a66764d13e034f92 Mon Sep 17 00:00:00 2001 From: georgefrick Date: Tue, 7 Apr 2015 22:44:50 -0500 Subject: [PATCH 1/2] update telnet.js so it doesn't crash on control key sends, since linemode TRAPSIG is not implemented. --- lib/telnet.js | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/lib/telnet.js b/lib/telnet.js index 042e634..8ac7790 100644 --- a/lib/telnet.js +++ b/lib/telnet.js @@ -20,22 +20,25 @@ var net = require('net') , Binary = require('binary') var COMMANDS = { - SE: 240 // end of subnegotiation parameters - , NOP: 241 // no operation - , DM: 242 // data mark - , BRK: 243 // break - , IP: 244 // suspend (a.k.a. "interrupt process") - , AO: 245 // abort output - , AYT: 246 // are you there? - , EC: 247 // erase character - , EL: 248 // erase line - , GA: 249 // go ahead - , SB: 250 // subnegotiation - , WILL: 251 // will - , WONT: 252 // wont - , DO: 253 // do - , DONT: 254 // dont - , IAC: 255 // interpret as command + EOF: 236 // Actual EOF character where supported. [ignoring] + , SUSP: 237 // Request a suspend. [ignoring] + , ABORT: 238 // Request an abort. [ignoring] + , SE: 240 // end of subnegotiation parameters + , NOP: 241 // no operation + , DM: 242 // data mark + , BRK: 243 // break + , IP: 244 // suspend (a.k.a. "interrupt process") + , AO: 245 // abort output + , AYT: 246 // are you there? + , EC: 247 // erase character + , EL: 248 // erase line + , GA: 249 // go ahead + , SB: 250 // subnegotiation + , WILL: 251 // will + , WONT: 252 // wont + , DO: 253 // do + , DONT: 254 // dont + , IAC: 255 // interpret as command } var OPTIONS = { @@ -89,6 +92,15 @@ COMMAND_IMPLS[COMMANDS.IAC] = function (bufs, i, event) { return event } +;['eof','susp','abort','ec','el'].forEach(function (command) { + var code = COMMANDS[command.toUpperCase()] + COMMAND_IMPLS[code] = function (bufs, i, event) { + // Needs to be converted to a NOP, we don't want to act on it. + event.buf = bufs.splice(0, i).toBuffer() + event.data = Buffer([ 241 ]) + return event + } +}) var OPTION_IMPLS = {} // these ones don't take any arguments From 43477032fd8282f4bac83958ab3b511e6c562f3e Mon Sep 17 00:00:00 2001 From: georgefrick Date: Tue, 7 Apr 2015 22:51:15 -0500 Subject: [PATCH 2/2] fix the test reusing the port the lib defaults to, avoiding the address error --- test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index 29b66cc..b3a370e 100644 --- a/test/test.js +++ b/test/test.js @@ -5,7 +5,7 @@ var net = require('net'); var client_responder = null; var client = null; var server = null; -var port = 1337; +var port = 10987; describe('telnet', function () { it('should export a function', function () {