Comparing version 0.1.2 to 0.1.3
@@ -42,3 +42,3 @@ var ssltunnel = require('./../lib/ssltunnel'); | ||
if (argv.role === 'client' && (!argv.clt_prv_cert || !argv.local_port)) | ||
if (argv.role === 'client' && (!argv.clt_prv_cert || argv.local_port == undefined)) | ||
{ | ||
@@ -73,3 +73,5 @@ // if this is a client component it must have client private key | ||
ssltunnel.createClient(options); | ||
ssltunnel.createClient(options, function(port) { | ||
console.log('Server is listening on port: ' + port); | ||
}); | ||
} | ||
@@ -83,4 +85,6 @@ else { | ||
ssltunnel.createServer(options); | ||
ssltunnel.createServer(options, function(port) { | ||
console.log('Server is listening on port: ' + port); | ||
}); | ||
} | ||
@@ -5,15 +5,15 @@ var tls = require('tls'); | ||
exports.createClient = function (options) | ||
exports.createClient = function (options, callback) | ||
{ | ||
options.client = true; | ||
createComponent(options); | ||
createComponent(options, callback); | ||
}; | ||
exports.createServer = function (options) | ||
exports.createServer = function (options, callback) | ||
{ | ||
options.server = true; | ||
createComponent(options); | ||
createComponent(options, callback); | ||
}; | ||
function createComponent(options) | ||
function createComponent(options, callback) | ||
{ | ||
@@ -73,3 +73,3 @@ if (options.client && options.server || | ||
serverPackage.createServer(serverOptions, function (proxySocket) { | ||
var server = serverPackage.createServer(serverOptions, function (proxySocket) { | ||
@@ -134,10 +134,18 @@ // the socket to the service (either ssltunnel server or real backend server) | ||
}).listen(serverPort); | ||
}); | ||
// calls the callback when the server is in listening state with the actual port | ||
server.on("listening", function () { | ||
console.log('listening on port: ' + server.address().port); | ||
callback(server.address().port); | ||
}); | ||
server.listen(serverPort); | ||
if (isClient) { | ||
console.log('Running \'client\' role. Listening on ' + options.server_port + | ||
console.log('Running \'client\' role. Listening on ' + server.address().port + | ||
', encrypting and forwarding to ssltunnel\'s server on ' + options.client_host + ':' + options.client_port); | ||
} else { | ||
console.log('Running \'server\' role. Listening on ' + options.server_port + | ||
console.log('Running \'server\' role. Listening on ' + server.address().port + | ||
', decrypting and forwarding to real server machine on ' + options.client_host + ':' + options.client_port); | ||
@@ -144,0 +152,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"description": "TCP over SSL / TLS tunnel", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"homepage": "https://github.com/anodejs/node-ssltunnel", | ||
@@ -8,0 +8,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24322
16
178