diff --git a/lib/telnet.js b/lib/telnet.js index 042e634..793df50 100644 --- a/lib/telnet.js +++ b/lib/telnet.js @@ -150,6 +150,9 @@ function parseCommand (bufs, i, event) { var command = bufs.get(i) event.commandCode = command event.command = COMMAND_NAMES[command] + if (event.command === undefined) { + throw "Unsupported command received: " + command; + } return COMMAND_IMPLS[command](bufs, i + 1, event) } @@ -198,7 +201,15 @@ function Socket (input, output) { var data = bufs.splice(0, i).toBuffer() self.emit('data', data) } - i = parse(bufs) + try { + i = parse(bufs); + } catch (e) { + console.log(e); + break; // somehow handle the error. break hangs the entire server; I'm + // guessing that the ctr+c is still in the buffer, and needs to + // be removed. Very new to node, however, so perhaps someone else + // will know how to do that. + } if (i === MORE) { debug('need to wait for more...') break