Skip to content

integrate tunnel-ssh without wrapping your existing codebase

License

Notifications You must be signed in to change notification settings

agebrock/inject-tunnel-ssh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inject-tunnel-ssh NPM version Dependency Status Coverage percentage

Integrate tunnel-ssh without wrapping your existing codebase

Installation

$ npm install --save inject-tunnel-ssh

Motivation and usage

The injector was build to support almost zero changes to your existing codebase.

Example

In the following example explains the integration (well injection) based on a little mongojs app..

var db = require('mongojs')('tunneltest1.com/test');
db.test.findOne(console.log);

For some we now need a tunnel to connect to the server..

  
    // ---- START INTEGRATION CODE -----
    require('inject-tunnel-ssh')([{
          dstPort: 27017,
          host: 'tunneltest1.com',
          username: 'root'
      }]).on('error',console.log);
    // ---- END INTEGRATION CODE -----
      
    var db = require('mongojs')('tunneltest1.com/test');
    db.test.findOne(console.log);

How it works

The injector is a module wrapping the native node "net.connection" function to inject the tunnel configuration.

Configuration

You can use the same properties as you would use in tunnel-ssh but in form of an array, since you can setup as many host / port combinations as you want. If no localPort is provided, the injector will search for a free one. For more information about the configuration please refer to the tunnel-ssh package.

If you get stuck using the lib please raise an issue or wait until we write a better readme.. ;)

License

MIT © Christoph Hagenbrock

About

integrate tunnel-ssh without wrapping your existing codebase

Resources

License

Stars

Watchers

Forks

Packages

No packages published