Multiple outgoing interface addresses
authorDarren <darren@darrenwhitlen.com>
Sat, 3 Aug 2013 21:13:04 +0000 (22:13 +0100)
committerDarren <darren@darrenwhitlen.com>
Sat, 3 Aug 2013 21:13:04 +0000 (22:13 +0100)
server/irc/connection.js

index 37aa13433ac107a2725c2e67d15e07628fc575a3..5cb8dc8d6898ce2d6a46e9e3a2aa7e9648058dc3 100644 (file)
@@ -168,6 +168,15 @@ IrcConnection.prototype.connect = function () {
                 host = dest_addr;
             }
 
+            // If we have an array of interfaces, select a random one
+            if (typeof outgoing !== 'string' && outgoing.length) {
+                outgoing = outgoing[Math.floor(Math.random() * outgoing.length)];
+            }
+
+            // Make sure we have a valid interface address
+            if (typeof outgoing !== 'string')
+                outgoing = '0.0.0.0';
+
         } else {
             // No config was found so use the default
             outgoing = '0.0.0.0';