Comparing version 0.2.2 to 0.2.3
@@ -5,4 +5,2 @@ var tls = require('tls'); | ||
var options = null; | ||
exports.createClient = function (options, callback) { | ||
@@ -18,34 +16,32 @@ options.client = true; | ||
var logLevels = ['error', 'warn', 'info', 'log']; | ||
var log = {}; | ||
function createComponent(options, callback) { | ||
function initLogs(options) { | ||
var logLevels = ['error', 'warn', 'info', 'log']; | ||
var log = {}; | ||
if (!options.log_level) | ||
{ | ||
options.log_level = 'log'; | ||
console.log('did not receive any log level. using default which is: ' + options.log_level); | ||
} | ||
function initLogs(options) { | ||
var found = false; | ||
for (var i = 0; i < logLevels.length; i++) { | ||
var logLevel = logLevels[i]; | ||
if (!found) { | ||
log[logLevel] = function(message) { | ||
console[logLevel](message); | ||
}; | ||
} else { | ||
log[logLevel] = function(message) {}; | ||
if (!options.log_level) { | ||
options.log_level = 'log'; | ||
console.log('did not receive any log level. using default which is: ' + options.log_level); | ||
} | ||
if (logLevel === options.log_level) | ||
{ | ||
found = true; | ||
var found = false; | ||
for (var i = 0; i < logLevels.length; i++) { | ||
var logLevel = logLevels[i]; | ||
if (!found) { | ||
log[logLevel] = function (message) { | ||
console[logLevel](message); | ||
}; | ||
} else { | ||
log[logLevel] = function (message) { }; | ||
} | ||
if (logLevel === options.log_level) { | ||
found = true; | ||
} | ||
} | ||
} | ||
} | ||
function createComponent(options, callback) { | ||
initLogs(options); | ||
@@ -114,3 +110,3 @@ | ||
log.info('Connected to the ssltunnel server'); | ||
log.log('Connected to the ssltunnel server'); | ||
@@ -134,3 +130,3 @@ // set TCP keep-alive if needed | ||
log.info('Connected to the real BE server'); | ||
log.log('Connected to the real BE server'); | ||
//serverStream.setKeepAlive(true, 30000); | ||
@@ -189,5 +185,3 @@ | ||
} | ||
}); | ||
} | ||
@@ -5,3 +5,3 @@ { | ||
"description": "TCP over SSL / TLS tunnel", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"homepage": "https://github.com/anodejs/node-ssltunnel", | ||
@@ -8,0 +8,0 @@ "repository": { |
164
README.md
@@ -11,3 +11,3 @@ [![Build Status](https://secure.travis-ci.org/anodejs/node-ssltunnel.png?branch=master)](http://travis-ci.org/#!/anodejs/node-ssltunnel) | ||
1. [Download and install latest node](http://nodejs.org/#download) (don't worry, it is small) (don't worry, it is small) | ||
1. [Download and install latest node](http://nodejs.org/#download) (don't worry, it is small) | ||
2. Enter CMD and run: ```npm install ssltunnel``` | ||
@@ -28,33 +28,33 @@ 3. The ssltunnel package now resides under ```./node_modules/ssltunnel``` | ||
``` | ||
dimast@DIMAST-LAPTOP /d/src/mygithub/temp | ||
$ openssl genrsa -out private.pem 2048 | ||
Generating RSA private key, 2048 bit long modulus | ||
...+++ | ||
............+++ | ||
e is 65537 (0x10001) | ||
dimast@DIMAST-LAPTOP /d/src/mygithub/temp | ||
$ openssl genrsa -out private.pem 2048 | ||
Generating RSA private key, 2048 bit long modulus | ||
...+++ | ||
............+++ | ||
e is 65537 (0x10001) | ||
dimast@DIMAST-LAPTOP /d/src/mygithub/temp | ||
$ ls | ||
private.pem | ||
dimast@DIMAST-LAPTOP /d/src/mygithub/temp | ||
$ ls | ||
private.pem | ||
dimast@DIMAST-LAPTOP /d/src/mygithub/temp | ||
$ openssl req -new -x509 -key private.pem -out public.pem -days 365 | ||
You are about to be asked to enter information that will be incorporated | ||
into your certificate request. | ||
What you are about to enter is what is called a Distinguished Name or a DN. | ||
There are quite a few fields but you can leave some blank | ||
For some fields there will be a default value, | ||
If you enter '.', the field will be left blank. | ||
----- | ||
Country Name (2 letter code) [AU]:IL | ||
State or Province Name (full name) [Some-State]: | ||
Locality Name (eg, city) []: | ||
Organization Name (eg, company) [Internet Widgits Pty Ltd]: | ||
Organizational Unit Name (eg, section) []: | ||
Common Name (eg, YOUR name) []:my_server | ||
Email Address []: | ||
dimast@DIMAST-LAPTOP /d/src/mygithub/temp | ||
$ openssl req -new -x509 -key private.pem -out public.pem -days 365 | ||
You are about to be asked to enter information that will be incorporated | ||
into your certificate request. | ||
What you are about to enter is what is called a Distinguished Name or a DN. | ||
There are quite a few fields but you can leave some blank | ||
For some fields there will be a default value, | ||
If you enter '.', the field will be left blank. | ||
----- | ||
Country Name (2 letter code) [AU]:IL | ||
State or Province Name (full name) [Some-State]: | ||
Locality Name (eg, city) []: | ||
Organization Name (eg, company) [Internet Widgits Pty Ltd]: | ||
Organizational Unit Name (eg, section) []: | ||
Common Name (eg, YOUR name) []:my_server | ||
Email Address []: | ||
dimast@DIMAST-LAPTOP /d/src/mygithub/temp | ||
$ ls | ||
private.pem public.pem | ||
dimast@DIMAST-LAPTOP /d/src/mygithub/temp | ||
$ ls | ||
private.pem public.pem | ||
``` | ||
@@ -70,24 +70,24 @@ | ||
``` | ||
d:\src\mygithub\ssltunnel\bin>ssltunnel.cmd -r server \ | ||
-p 54443 \ | ||
-h my_ssltunnel_server_host \ | ||
--remote_port 8080 \ | ||
--remote_host my_host \ | ||
--srv_pub_cert ..\testcerts\local_public.pem \ | ||
--clt_pub_cert ..\testcerts\cc_public_test.pem \ | ||
--srv_prv_cert ..\testcerts\local_private.pem | ||
d:\src\ssltunnel\bin>ssltunnel.cmd -r server \ | ||
--proxy_port 54443 \ | ||
--server_port 8080 \ | ||
--server_host my_host \ | ||
--srv_pub_cert ..\testcerts\sc_public.pem \ | ||
--clt_pub_cert ..\testcerts\cc_public.pem \ | ||
--srv_prv_cert ..\testcerts\sc_private.pem \ | ||
Running 'server' role. Listening on 54443, decrypting and forwarding to real server machine on my_host:8080. | ||
Running 'server' role. Listening on 54443, decrypting and forwarding to real server machine on my_host:8080 | ||
``` | ||
``` | ||
d:\src\mygithub\ssltunnel\bin>ssltunnel.cmd -r client \ | ||
-p 54443 \ | ||
-h my_ssltunnel_server_host \ | ||
--local_port 54080 \ | ||
--srv_pub_cert ..\testcerts\local_public.pem \ | ||
--clt_pub_cert ..\testcerts\cc_public_test.pem \ | ||
--clt_prv_cert ..\testcerts\cc_private_test.pem | ||
d:\src\ssltunnel\bin>ssltunnel.cmd -r client \ | ||
--proxy_port 54080 \ | ||
--server_port 54443 \ | ||
--server_host my_ssltunnel_server_host \ | ||
--srv_pub_cert ..\testcerts\sc_public.pem \ | ||
--clt_pub_cert ..\testcerts\cc_public.pem \ | ||
--clt_prv_cert ..\testcerts\cc_private.pem \ | ||
Running 'client' role. Listening on 54080, encrypting and forwarding to ssltunnel's server on my_ssltunnel_server_host:54443. | ||
Running 'client' role. Listening on 54080, encrypting and forwarding to ssltunnel's server on my_ssltunnel_server_host:54443 | ||
``` | ||
@@ -101,16 +101,22 @@ | ||
``` | ||
d:\src\mygithub\ssltunnel\bin>ssltunnel.cmd | ||
Usage node d:\src\mygithub\ssltunnel\bin\run_ssltunnel.js | ||
d:\src\ssltunnel\bin>ssltunnel | ||
Usage node d:\src\ssltunnel\bin\run_ssltunnel.js | ||
Options: | ||
-r, --role The role of the tunnel component, either 'client' or 'server' [required] | ||
-p, --port The port of ssltunnel's server [required] | ||
-h, --host The hostname of ssltunnel's server [default: "localhost"] | ||
--local_port The local port ssltunnel's client will listen on | ||
--remote_port The port on the remote machine ssltunnel's server will connect to | ||
--remote_host The hostname of the remote machine ssltunnel's server will connect to [default: "localhost"] | ||
--srv_pub_cert Public certificate file for ssltunnel's server [required] | ||
-r, --role The role of the tunnel component, either 'client' or 'server' [required] | ||
--proxy_port The proxy listener's port [required] | ||
--server_host The server's hostname. Either ssltunnel's server role or back-end server [default: "localhost"] | ||
--server_port The server's port. Either ssltunnel's server role or back-end server [required] | ||
--log_level SSLTunnel logging level. One of: 'error', 'warn', 'info', or 'log' [default: "log"] | ||
--keep_alive Use TCP keep-alive when connecting to an sslserver. | ||
Provide keep-alive delay in ms. Use negative value for | ||
turning keep-alive off. Relevant for client role only. [default: "30000"] | ||
--srv_pub_cert Public certificate file for ssltunnel's server [required] | ||
--srv_prv_cert Private certificate file for ssltunnel's server | ||
--clt_pub_cert Public certificate for ssltunnel's client [required] | ||
--clt_pub_cert Public certificate for ssltunnel's client [required] | ||
--clt_prv_cert Private certificate for ssltunnel's client | ||
Missing required arguments: r, proxy_port, server_port, srv_pub_cert, clt_pub_cert | ||
``` | ||
@@ -124,33 +130,33 @@ | ||
var ssltunnel = require('ssltunnel'); | ||
ssltunnel.createServer(options) | ||
ssltunnel.createClient(options) | ||
``` | ||
The options are basically property bag with data similar to what arguments contain. Feel free to see usage example in ```bin/run_ssltunnel.js``` | ||
var options = { | ||
'proxy_port' : 8080, | ||
'server_host' : my_host, | ||
'server_port' : 54443, | ||
//... | ||
} | ||
Please see detailed list below: | ||
ssltunnel.createServer(options); | ||
* options.client_port: | ||
For createServer() this is a remote machine port. | ||
For createClient() this is a ssltunnel's server port. | ||
// or | ||
* options.client_host: | ||
For createServer() this is a remote machine host. | ||
For createClient() this is a ssltunnel's server host. | ||
ssltunnel.createClient(options); | ||
``` | ||
* options.server_port: | ||
For createServer() this is a listening port for ssltunnel's server. | ||
For createClient() this is a listening port for ssltunnel's client. | ||
The options are basically property bag with data similar to what arguments contain. | ||
See [run_ssltunnel.js](https://github.com/anodejs/node-ssltunnel/blob/master/bin/run_ssltunnel.js) for usage example. | ||
* options.server_public_cert: Server public certificate. | ||
The full list is below: | ||
* options.server_private_cert: | ||
Server private certificate. Not needed for createClient(). | ||
* _proxy_port_ : the listening proxy port. Receives cleartext for *client* role and ciphertext for *server* role. | ||
* _server_port_ : the port of the server to forward the data to. | ||
* _server_host_ : the host name of the server to forward the data to. | ||
* _client_public_cert_ : client's role public certificate. | ||
* _server_public_cert_ : client's role private certificate. | ||
* _client_private_cert_ : servers's role public certificate. | ||
* _server_private_cert_ : servers's role public certificate. | ||
* _log_level_ : One of: 'error', 'warn', 'info', or 'log'. | ||
* _keep_alive_ : Whether to use TCP keep alive when connecting to *server* role. This setting is relevant to *client* role only. | ||
* options.client_public_cert: | ||
Client public certificate. | ||
* options.client_private_cert: | ||
Client private certificate. Not needed for createServer(). | ||
## Enjoy! |
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
38859
18
158
201