mscdex/ssh2 — pull request #138 by vivekg342 (2014-05-30 04:03:39+00:00)
Title: Support for connection hopping with configuration

Connection hopping with configuration. Options can take an additional parameter tunnel and goes hopping recursively.
Events 'tunnel:ready', 'tunnel:error' for listening on inner connections.

```
var Connection = require('ssh2/lib/TunneledConnection');

var c = new Connection();
c.on('ready', function() {
console.log('Connection :: ready');
c.exec('uptime', function(err, stream) {
if (err) throw err;
stream.on('data', function(data, extended) {
console.log((extended === 'stderr' ? 'STDERR: ' : 'STDOUT: ')
+ data);
});
stream.on('exit', function(code, signal) {
c.end();
});
});
});

c.on('tunnel:error', function(err, host) {
console.log(host + ' :: error :: ' + err);
});

c.on('tunnel:ready', function(host){
console.log(host + ":: ready")
});

c.connect({
host: '192.168.100.100',
port: 22,
username: 'frylock',
privateKey: require('fs').readFileSync('/here/is/my/key')
tunnel: {
host: '192.168.100.101',
port: 22,
username: 'frylock2',
privateKey: require('fs').readFileSync('/here/is/my/key')
tunnel: {
..........
}
}
});
```