TooTallNate / node-telnet

Telnet implementation for Node.js
87 stars 30 forks source link

Add IP command and TIMING-MARK option to fix issue #1 #3

Closed danielbolan closed 11 years ago

danielbolan commented 11 years ago

So it looks like hitting CTRL-C (in Linux 3.2.0, in my case) sends two commands:

IAC IP             (ff f4)
IAC DO TIMING-MARK (ff fd 06)

I've associated two functions to work the IP command and the TIMING-MARK option so it at the very least doesn't crash. The following code should all work when you hit CTRL-C:

var telnet = require('telnet');
telnet.createServer(function(client) {
    console.log('CLIENT CONNECTED');
    client.write('hello!\n');
    client.pipe(client);

    client.on('ip',function() {
        console.log('INTERRUPT PROCESS');
        client.end();
    });

    client.on('timing mark', function() {
        console.log('TIMING-MARK');
    });

    client.on('end',function() {
        console.log('CLIENT DISCONNECTED');
    });
}).listen(9999);

A few things worth noting:

Hopefully this is fixes #1 to satisfaction.

danielbolan commented 11 years ago

Yikes, I didn't know that every commit I make to my fork automatically gets added to the pull request... Sorry, if you don't want my new changes, just let me know and I'll close the pull request.

Edit: Yeah, I guess I didn't completely understand how pull requests work. Probably shouldn't have created it from my master branch, I think. I'll close this and put the above four commits into their own branch so I can create a pull request from that instead if requested. Sorry for cluttering your issues section...