]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Allow for skipping clone checking before DNS is complete.
authorDaniel Vassdal <shutter@canternet.org>
Mon, 1 Jul 2013 19:31:36 +0000 (12:31 -0700)
committerDaniel Vassdal <shutter@canternet.org>
Tue, 2 Jul 2013 17:55:51 +0000 (10:55 -0700)
docs/conf/inspircd.conf.example
include/configreader.h
include/users.h
src/configreader.cpp
src/usermanager.cpp
src/users.cpp

index 23a87dc5e7e45d29dbc257f5aa130965089562d9..7531117b9ad973dd1ed0beb353289cd2cbf0c3a1 100644 (file)
              # connections. If defined, it sets a soft max connections value.
              softlimit="12800"
 
+             # clonesonconnect: If this is set to false, we won't check for clones
+             # on initial connection, but only after the DNS check is done.
+             # This can be useful where your main class is more restrictive
+             # than some other class a user can be assigned after DNS lookup is complete.
+             # Turning this option off will make the server spend more time on users we may
+             # potentially not want. Normally this should be neglible, though.
+             # Default value is true
+             clonesonconnect="true"
+
              # quietbursts: When syncing or splitting from a network, a server
              # can generate a lot of connect and quit messages to opers with
              # +C and +Q snomasks. Setting this to yes squelches those messages,
index a17c5cf3eb294223ca2115e02ee33c3318c96f5f..51ced2ec7ddce5b09ffe86dd5ef9b041305232d4 100644 (file)
@@ -373,6 +373,13 @@ class CoreExport ServerConfig
         */
        int MaxConn;
 
+       /** If we should check for clones during CheckClass() in AddUser()
+        * Setting this to false allows to not trigger on maxclones for users
+        * that may belong to another class after DNS-lookup is complete.
+        * It does, however, make the server spend more time on users we may potentially not want.
+        */
+       bool CCOnConnect;
+
        /** The soft limit value assigned to the irc server.
         * The IRC server will not allow more than this
         * number of local users.
index 73ecba0ab51d47c7166fefc9bcccd3ef123aa161..28bf8b05bb8e4472ea347e16dda41cac08755fb8 100644 (file)
@@ -750,7 +750,7 @@ class CoreExport LocalUser : public User, public InviteBase
 
        /** Call this method to find the matching \<connect> for a user, and to check them against it.
         */
-       void CheckClass();
+       void CheckClass(bool clone_count = true);
 
        /** Server address and port that this user is connected to.
         */
index 427bc79bf0a7ee76a19a092f7f430aab2b7054af..31287b396c27348cbf5d967e32f05df706d88408 100644 (file)
@@ -387,6 +387,7 @@ void ServerConfig::Fill()
        SuffixPart = options->getString("suffixpart");
        FixedPart = options->getString("fixedpart");
        SoftLimit = ConfValue("performance")->getInt("softlimit", ServerInstance->SE->GetMaxFds());
+       CCOnConnect = ConfValue("performance")->getBool("clonesonconnect", true);
        MaxConn = ConfValue("performance")->getInt("somaxconn", SOMAXCONN);
        MoronBanner = options->getString("moronbanner", "You're banned!");
        ServerDesc = ConfValue("server")->getString("description", "Configure Me");
index 8a05c811c37476889e04409b6c953f6ecd015945..e7d1fd05c2bb888eed24d908e7ab92f80660236a 100644 (file)
@@ -112,7 +112,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
         * Check connect class settings and initialise settings into User.
         * This will be done again after DNS resolution. -- w00t
         */
-       New->CheckClass();
+       New->CheckClass(ServerInstance->Config->CCOnConnect);
        if (New->quitting)
                return;
 
index 468c2aa36e92980402ccf29c8dd22f31c6baa803..0dc9cea573ced77a3893978e7e66986058b6dbb8 100644 (file)
@@ -600,7 +600,7 @@ void User::UnOper()
 /*
  * Check class restrictions
  */
-void LocalUser::CheckClass()
+void LocalUser::CheckClass(bool clone_count)
 {
        ConnectClass* a = this->MyClass;
 
@@ -614,19 +614,22 @@ void LocalUser::CheckClass()
                ServerInstance->Users->QuitUser(this, a->config->getString("reason", "Unauthorised connection"));
                return;
        }
-       else if ((a->GetMaxLocal()) && (ServerInstance->Users->LocalCloneCount(this) > a->GetMaxLocal()))
+       else if (clone_count)
        {
-               ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (local)");
-               if (a->maxconnwarn)
-                       ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString().c_str());
-               return;
-       }
-       else if ((a->GetMaxGlobal()) && (ServerInstance->Users->GlobalCloneCount(this) > a->GetMaxGlobal()))
-       {
-               ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (global)");
-               if (a->maxconnwarn)
-                       ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString().c_str());
-               return;
+               if ((a->GetMaxLocal()) && (ServerInstance->Users->LocalCloneCount(this) > a->GetMaxLocal()))
+               {
+                       ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (local)");
+                       if (a->maxconnwarn)
+                               ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString().c_str());
+                       return;
+               }
+               else if ((a->GetMaxGlobal()) && (ServerInstance->Users->GlobalCloneCount(this) > a->GetMaxGlobal()))
+               {
+                       ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (global)");
+                       if (a->maxconnwarn)
+                               ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString().c_str());
+                       return;
+               }
        }
 
        this->nping = ServerInstance->Time() + a->GetPingTime() + ServerInstance->Config->dns_timeout;