]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add a setting to <connect> allowing the threshold for activation of the penalty syste...
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 19 Oct 2009 18:32:11 +0000 (18:32 +0000)
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 19 Oct 2009 18:32:11 +0000 (18:32 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11922 e03df62e-2008-0410-955e-edbf42e46eb7

conf/inspircd.conf.example
include/users.h
src/command_parse.cpp
src/configreader.cpp
src/users.cpp

index 726605b16b937808cd641004e873644e27e7a71a..d5c9874df0955cb8c622b1cf294c702d48bb88a2 100644 (file)
          # recvq: amount of data allowed in a client's queue before they are dropped.
          recvq="8192"
 
+         # threshold: This specifies the seconds worth of penalty a user is allowed to have
+         # before fake lag is applied to them.  If this value is set too low, every action will cause throttling.
+         # Set to 0 to disable.
+         threshold="10"
+
          # localmax: Maximum local connections per IP.
          localmax="3"
 
index 385cd2dfe5703fc1f6412d634eed58de3c11f559..42d04696acef30e4cc8f7fab2c5c2f238938e239 100644 (file)
@@ -108,6 +108,10 @@ struct CoreExport ConnectClass : public refcountbase
         */
        unsigned long recvqmax;
 
+       /** Seconds worth of penalty before penalty system activates
+        */
+       unsigned long penaltythreshold;
+
        /** Local max when connecting by this connection class
         */
        unsigned long maxlocal;
@@ -181,6 +185,13 @@ struct CoreExport ConnectClass : public refcountbase
                return (recvqmax ? recvqmax : 4096);
        }
 
+       /** Returns the penalty threshold value
+        */
+       unsigned long GetPenaltyThreshold()
+       {
+               return penaltythreshold;
+       }
+
        /** Returusn the maximum number of local sessions
         */
        unsigned long GetMaxLocal()
index fe0aab3b98247d45a96333a7c1688b981087303f..6dd4e663e04726411b63c904d201faab6d5b785f 100644 (file)
@@ -253,7 +253,7 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd)
        {
                // If it *doesn't* exist, give it a slightly heftier penalty than normal to deter flooding us crap
                user->IncreasePenalty(cm != cmdlist.end() ? cm->second->Penalty : 2);
-               do_more = (user->Penalty < 10);
+               do_more = (user->GetClass()->GetPenaltyThreshold() && ((unsigned long)user->Penalty < user->GetClass()->GetPenaltyThreshold()));
        }
 
 
index 545ff86c2e3ddcc6e308cf45f6183c3f3041f248..879aeaa8ec701637b13c0594e50030c2fc5f93ec 100644 (file)
@@ -724,6 +724,7 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
                        me->softsendqmax = tag->getInt("softsendq", me->softsendqmax);
                        me->hardsendqmax = tag->getInt("hardsendq", me->hardsendqmax);
                        me->recvqmax = tag->getInt("recvq", me->recvqmax);
+                       me->penaltythreshold = tag->getInt("threshold", me->penaltythreshold);
                        me->maxlocal = tag->getInt("localmax", me->maxlocal);
                        me->maxglobal = tag->getInt("globalmax", me->maxglobal);
                        me->port = tag->getInt("port", me->port);
index 4707fdc39c43beddca72aaf68a0c77c1e05a575c..1675b621b9f1a3b440b119e823f6e08be66f2f67 100644 (file)
@@ -1778,7 +1778,7 @@ const std::string FakeUser::GetFullRealHost()
 ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask)
        : config(tag), type(t), name("unnamed"), registration_timeout(0), host(mask),
        pingtime(0), pass(""), hash(""), softsendqmax(0), hardsendqmax(0),
-       recvqmax(0), maxlocal(0), maxglobal(0), maxchans(0), port(0), limit(0)
+       recvqmax(0), penaltythreshold(0), maxlocal(0), maxglobal(0), maxchans(0), port(0), limit(0)
 {
 }
 
@@ -1787,7 +1787,7 @@ ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, cons
        registration_timeout(parent.registration_timeout), host(mask),
        pingtime(parent.pingtime), pass(parent.pass), hash(parent.hash),
        softsendqmax(parent.softsendqmax), hardsendqmax(parent.hardsendqmax),
-       recvqmax(parent.recvqmax), maxlocal(parent.maxlocal),
+       recvqmax(parent.recvqmax), penaltythreshold(parent.penaltythreshold), maxlocal(parent.maxlocal),
        maxglobal(parent.maxglobal), maxchans(parent.maxchans),
        port(parent.port), limit(parent.limit)
 {
@@ -1804,6 +1804,7 @@ void ConnectClass::Update(const ConnectClass* src)
        softsendqmax = src->softsendqmax;
        hardsendqmax = src->hardsendqmax;
        recvqmax = src->recvqmax;
+       penaltythreshold = src->penaltythreshold;
        maxlocal = src->maxlocal;
        maxglobal = src->maxglobal;
        limit = src->limit;