Skip to content

Instantly share code, notes, and snippets.

@kevinlebrun
Created February 29, 2012 09:52
Show Gist options
  • Save kevinlebrun/64273d5a67da4f8bcf78 to your computer and use it in GitHub Desktop.
Save kevinlebrun/64273d5a67da4f8bcf78 to your computer and use it in GitHub Desktop.
Node telnet and local REPL
#!/usr/bin/env node
var net = require('net'),
repl = require('repl');
var mood = function () {
var m = [ "^__^", "-___-;", ">.<", "<_>" ];
return m[Math.floor(Math.random() * m.length)];
};
net.createServer(function (socket) {
var remote = repl.start('node::remote> ', socket);
remote.context.mood = mood;
remote.context.bonus = 'UNLOCKED';
}).listen(5001);
console.log('Remote REPL started on port 5001.');
var local = repl.start('node::local> ');
local.context.mood = mood;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment