Connection limiting
authorDarren <darren@Darrens-MacBook-Pro.local>
Wed, 3 Apr 2013 18:29:21 +0000 (19:29 +0100)
committerDarren <darren@Darrens-MacBook-Pro.local>
Wed, 3 Apr 2013 18:29:21 +0000 (19:29 +0100)
1  2 
config.example.js
server/irc/state.js

Simple merge
index cd99df446a09792fbfcef39ebde25eb785711d94,4b368c173dfb5c7ab77cd39f22a6c5afdc24bc04..4f3f764de839f58e3628dbc495c382e46387d1f1
@@@ -35,6 -36,17 +36,17 @@@ module.exports = State
  State.prototype.connect = function (hostname, port, ssl, nick, user, pass, callback) {
      var that = this;
      var con, con_num;
 -    
++
+     // Check the per-server limit on the number of connections
+     if ((global.config.max_server_conns > 0) &&
+         (!global.config.restrict_server) &&
+         (!(global.config.webirc_pass && global.config.webirc_pass[hostname])) &&
+         (!(global.config.ip_as_username && _.contains(global.config.ip_as_username, hostname))) &&
+         (global.servers.numOnHost(hostname) >= global.config.max_server_conns))
+     {
+         return callback('Too many connections to host', {host: hostname, limit: global.config.max_server_conns});
+     }
      con = new IrcConnection(
          hostname,
          port,