From f014109bb395b2c205a167e7b2487ff083453aac Mon Sep 17 00:00:00 2001 From: Felis Catus Date: Mon, 14 Sep 2015 06:46:20 +0300 Subject: [PATCH 1/4] Allow reusing existing socket Required for using irc with socks client --- lib/irc.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/irc.js b/lib/irc.js index 0ad258a3..4ae9cf88 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -39,6 +39,7 @@ function Client(server, nick, opt) { realName: 'nodeJS IRC client', port: 6667, localAddress: null, + existingSocket: null, debug: false, showErrors: false, autoRejoin: false, @@ -711,6 +712,10 @@ Client.prototype.connect = function(retryCount, callback) { util.log(self.conn.authorizationError); } }); + } else if (self.opt.existingSocket) { + // must be an already connected socket, e.g. from socks proxy + self.conn = self.opt.existingSocket; + (self._connectionHandler.bind(self))(); } else { self.conn = net.createConnection(connectionOpts, self._connectionHandler.bind(self)); } From 1989b998be32d8fbb146b86115618719778b0c7a Mon Sep 17 00:00:00 2001 From: Felis Catus Date: Sat, 30 Nov 2019 00:25:23 +0200 Subject: [PATCH 2/4] allow attaching to existing connection, e.g. from socks proxy --- lib/irc.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/irc.js b/lib/irc.js index 265962e6..29627d66 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -40,7 +40,7 @@ function Client(server, nick, opt) { realName: 'nodeJS IRC client', port: 6667, localAddress: null, - existingSocket: null, + existingSocket: null, debug: false, showErrors: false, autoRejoin: false, @@ -794,9 +794,10 @@ Client.prototype.connect = function(retryCount, callback) { } }); } else if (self.opt.existingSocket) { - // must be an already connected socket, e.g. from socks proxy - self.conn = self.opt.existingSocket; - (self._connectionHandler.bind(self))(); + // must be an already connected socket, e.g. from socks proxy + self.conn = self.opt.existingSocket; + // call connection handler asynchronously, emulating connection success + setTimeout(self._connectionHandler.bind(self), 0); } else { self.conn = net.createConnection(connectionOpts, self._connectionHandler.bind(self)); } From 7378317849b16b037f33c1cd62b6535dc6d3204a Mon Sep 17 00:00:00 2001 From: Felis Catus Date: Sat, 30 Nov 2019 00:38:13 +0200 Subject: [PATCH 3/4] add myself to contributors --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f70dcdbe..7d93d4e7 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "Chris Nehren ", "Henri Niemeläinen ", "Alex Miles ", - "Simmo Saan " + "Simmo Saan ", + "e-neko " ], "repository": { "type": "git", From 2724144a6decec672900d521c7bf62d13ced7e9a Mon Sep 17 00:00:00 2001 From: Felis Catus Date: Sat, 30 Nov 2019 02:04:01 +0200 Subject: [PATCH 4/4] fix whitespace issues --- lib/irc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/irc.js b/lib/irc.js index 29627d66..a62647c0 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -40,7 +40,7 @@ function Client(server, nick, opt) { realName: 'nodeJS IRC client', port: 6667, localAddress: null, - existingSocket: null, + existingSocket: null, debug: false, showErrors: false, autoRejoin: false, @@ -794,7 +794,7 @@ Client.prototype.connect = function(retryCount, callback) { } }); } else if (self.opt.existingSocket) { - // must be an already connected socket, e.g. from socks proxy + // must be an already connected socket, e.g. from socks proxy self.conn = self.opt.existingSocket; // call connection handler asynchronously, emulating connection success setTimeout(self._connectionHandler.bind(self), 0);