Net. interface binding per outgoing IRC connection
authorDarren <darren@darrenwhitlen.com>
Sat, 2 Nov 2013 13:01:31 +0000 (13:01 +0000)
committerDarren <darren@darrenwhitlen.com>
Sat, 2 Nov 2013 13:01:31 +0000 (13:01 +0000)
server/irc/connection.js

index a2d1c131d9160c9fc51bd6f06c8a58061de7da3a..0bfca1dfc1310633bae6dd25e610a9b1e6c7ebd8 100644 (file)
@@ -101,6 +101,9 @@ var IrcConnection = function (hostname, port, ssl, nick, user, options, state, c
         this.socks = false;
     }
 
+    // Net. interface this connection should be made through
+    this.outgoing_interface = false;
+
     // Options sent by the IRCd
     this.options = Object.create(null);
     this.cap = {requested: [], enabled: []};
@@ -160,7 +163,12 @@ IrcConnection.prototype.connect = function () {
         var outgoing;
 
         // Decide which net. interface to make the connection through
-        if (global.config.outgoing_address) {
+        if (that.outgoing_interface) {
+            // An specific interface has been given for this connection
+            outgoing = this.outgoing_interface;
+
+        } else if (global.config.outgoing_address) {
+            // Pick an interface from the config
             if ((family === 'IPv6') && (global.config.outgoing_address.IPv6)) {
                 outgoing = global.config.outgoing_address.IPv6;
             } else {