Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 37 lines (31 sloc) 758 Bytes
#!/usr/bin/env node
var net = require('net')
var sock = net.connect(process.argv[2] || 1337, process.argv[3]);
sock.pipe(process.stdout);
sock.on('connect', function () {
process.stdin.setRawMode(true);
process.stdin.resume();
});
sock.on('close', function done () {
process.stdin.setRawMode(false);
process.stdin.pause();
sock.removeListener('close', done);
});
process.stdin.on('end', function () {
sock.destroy();
console.log();
});
process.stdin.on('data', function (b) {
if (b.length === 1 && b[0] === 3) {
process.stdin.emit('end');
}
else {
for(var i = 0; i < b.length; i++) {
if (b[i] === '\r'.charCodeAt(0)) {
b[i] = '\n'.charCodeAt(0);
}
}
sock.write(b);
}
});
process.stdin.resume();
Jump to Line
Something went wrong with that request. Please try again.