diff --git a/README.md b/README.md index 2f1e8d0..56d3b8f 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ tunnel({ dstPort: 8000, //srcHost: '127.0.0.1', // default //srcPort: dstPort // default is the same as dstPort + //privateKey: require('fs').readFileSync('/Your/Private/Key'); }, function(error, clientConnection) { // }); @@ -35,6 +36,8 @@ var conn = tunnel({ dstPort: 0, // dynamically choose an open port on tunneltest.com //srcHost: '127.0.0.1', // default srcPort: 8000, // must be specified if dstPort=0 + //privateKey: require('fs').readFileSync('/Your/Private/Key'); + }, function (error, clientConnection) { // }); diff --git a/lib/config.js b/lib/config.js index 4eae741..828e636 100644 --- a/lib/config.js +++ b/lib/config.js @@ -9,7 +9,8 @@ function createConfig(userConfig) { srcHost: 'localhost', dstPort: null, dstHost: 'localhost', - localHost: 'localhost' + localHost: 'localhost', + privateKey: null }); // Try to use ssh-agent if no auth information was set @@ -17,6 +18,10 @@ function createConfig(userConfig) { config.agent = config.agent || process.env.SSH_AUTH_SOCK; } + if (userConfig.privateKey !== null) { + config.privateKey = userConfig.privateKey + } + // No local route, no remote route.. exit here if (config.dstPort === null || !config.dstHost || !config.host) { throw new Error('invalid configuration.');