Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions lib/telnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down