From 29bc206650b2226f678dddf2bb90b89207649350 Mon Sep 17 00:00:00 2001 From: Darren Date: Thu, 23 Jan 2014 21:09:59 +0000 Subject: [PATCH] Connecting to a SSL/TLS kiwi proxy --- server/irc/connection.js | 2 +- server/proxy.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/server/irc/connection.js b/server/irc/connection.js index 5e534a3..16c99f6 100644 --- a/server/irc/connection.js +++ b/server/irc/connection.js @@ -102,7 +102,7 @@ var IrcConnection = function (hostname, port, ssl, nick, user, options, state, c this.socks = false; } - // Kiwi proxy info may be set within a server module. {port: 7779, host: 'kiwi.proxy.com'} + // Kiwi proxy info may be set within a server module. {port: 7779, host: 'kiwi.proxy.com', ssl: false} this.proxy = false; // Net. interface this connection should be made through diff --git a/server/proxy.js b/server/proxy.js index 91dbbf1..5950dcf 100644 --- a/server/proxy.js +++ b/server/proxy.js @@ -233,12 +233,13 @@ ProxyPipe.prototype.startPiping = function() { * ProxySocket * Transparent socket interface to a kiwi proxy */ -function ProxySocket(proxy_port, proxy_addr, meta) { +function ProxySocket(proxy_port, proxy_addr, meta, proxy_opts) { stream.Duplex.call(this); this.connected_fn = null; this.proxy_addr = proxy_addr; this.proxy_port = proxy_port; + this.proxy_opts = proxy_opts || {}; this.meta = meta || {}; this.state = 'disconnected'; @@ -263,7 +264,9 @@ ProxySocket.prototype.connect = function(dest_port, dest_addr, connected_fn) { } debug('[KiwiProxy] Connecting to proxy ' + this.proxy_addr + ':' + this.proxy_port.toString()); - this.socket = net.connect(this.proxy_port, this.proxy_addr, this._onSocketConnect.bind(this)); + this.socket = this.proxy_opts.ssl ? + tls.connect(this.proxy_port, this.proxy_addr, this._onSocketConnect.bind(this)) : + net.connect(this.proxy_port, this.proxy_addr, this._onSocketConnect.bind(this)); this.socket.setTimeout(10000); this.socket.on('data', this._onSocketData.bind(this)); -- 2.25.1