Adding SSL support, release 0.2.3
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
var net = require('net');
|
||||
var tls = require('tls');
|
||||
var createBufferSegment = require('../../common/bufferSegment');
|
||||
|
||||
const MaxSendPacketSize = 64 * 1024;
|
||||
@ -136,11 +137,16 @@ TcpConnection.prototype._closeInternal = function(err, reason) {
|
||||
};
|
||||
|
||||
TcpConnection.createConnectingConnection = function(
|
||||
log, connectionId, remoteEndPoint, connectionTimeout,
|
||||
onConnectionEstablished, onConnectionFailed, onConnectionClosed
|
||||
log, connectionId, remoteEndPoint, ssl, targetHost, validateServer,
|
||||
connectionTimeout, onConnectionEstablished, onConnectionFailed, onConnectionClosed
|
||||
) {
|
||||
var connection = new TcpConnection(log, connectionId, remoteEndPoint, onConnectionClosed);
|
||||
var socket = net.connect(remoteEndPoint.port, remoteEndPoint.host);
|
||||
var provider = ssl ? tls : net;
|
||||
var options = {
|
||||
servername: targetHost,
|
||||
rejectUnauthorized: validateServer
|
||||
};
|
||||
var socket = provider.connect(remoteEndPoint.port, remoteEndPoint.host, options);
|
||||
function onError(err) {
|
||||
if (onConnectionFailed)
|
||||
onConnectionFailed(connection, err);
|
||||
|
@ -38,15 +38,14 @@ function TcpPackageConnection(
|
||||
this._framer = new LengthPrefixMessageFramer();
|
||||
this._framer.registerMessageArrivedCallback(this._incomingMessageArrived.bind(this));
|
||||
|
||||
//TODO ssl
|
||||
var self = this;
|
||||
this._connection = TcpConnection.createConnectingConnection(
|
||||
log,
|
||||
connectionId,
|
||||
remoteEndPoint,
|
||||
//ssl,
|
||||
//targetHost,
|
||||
//validateServer,
|
||||
ssl,
|
||||
targetHost,
|
||||
validateServer,
|
||||
timeout,
|
||||
function(tcpConnection) {
|
||||
log.debug("TcpPackageConnection: connected to [%j, L%j, %s].", tcpConnection.remoteEndPoint, tcpConnection.localEndPoint, connectionId);
|
||||
|
Reference in New Issue
Block a user