From: Darren Date: Sun, 14 Jul 2013 12:37:24 +0000 (+0100) Subject: Connecting to the correct host for outgoing connections X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ddae94f590c5f6f3e865580bc66e4a8adf6c73f6;p=KiwiIRC.git Connecting to the correct host for outgoing connections --- diff --git a/server/irc/connection.js b/server/irc/connection.js index 722be5d..4239b6e 100644 --- a/server/irc/connection.js +++ b/server/irc/connection.js @@ -145,6 +145,11 @@ IrcConnection.prototype.connect = function () { outgoing = global.config.outgoing_address.IPv6; } else { outgoing = global.config.outgoing_address.IPv4 || '0.0.0.0'; + + // We don't have an IPv6 interface but dest_addr may still resolve to + // an IPv4 address. Reset `host` and try connecting anyway, letting it + // fail if an IPv4 resolved address is not found + host = dest_addr; } } else { @@ -155,7 +160,7 @@ IrcConnection.prototype.connect = function () { // Are we connecting through a SOCKS proxy? if (this.socks) { that.socket = Socks.connect({ - host: that.irc_host.hostname, + host: host, port: that.irc_host.port, ssl: that.ssl, rejectUnauthorized: global.config.reject_unauthorised_certificates @@ -171,7 +176,7 @@ IrcConnection.prototype.connect = function () { if (that.ssl) { that.socket = tls.connect({ - host: that.irc_host.hostname, + host: host, port: that.irc_host.port, rejectUnauthorized: global.config.reject_unauthorised_certificates, localAddress: outgoing