]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/command_parse.cpp
Patch: /rehash (not /rehash ssl) will now rebind SSL ports, but not dh params etc...
[user/henk/code/inspircd.git] / src / command_parse.cpp
index a10a19fb90163a1201a72b3b3b4e3d930f001543..23fa6a6e389fd66d4ccadc7501f998b19cddcb10 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
 #include <dlfcn.h>
 #endif
 
-int InspIRCd::OperPassCompare(const char* data,const char* input, int tagnumber)
+int InspIRCd::PassCompare(Extensible* ex, const char* data,const char* input, const char* hashtype)
 {
        int MOD_RESULT = 0;
-       FOREACH_RESULT_I(this,I_OnOperCompare,OnOperCompare(data, input, tagnumber))
+       FOREACH_RESULT_I(this,I_OnPassCompare,OnPassCompare(ex, data, input, hashtype))
        if (MOD_RESULT == 1)
                return 0;
        if (MOD_RESULT == -1)
@@ -219,26 +219,29 @@ CmdResult CommandParser::CallHandler(const std::string &commandname,const char**
 void CommandParser::DoLines(User* current, bool one_only)
 {
        // while there are complete lines to process...
-       int floodlines = 0;
+       unsigned int floodlines = 0;
 
        while (current->BufferIsReady())
        {
-               if (ServerInstance->Time() > current->reset_due)
+               if (current->MyClass)
                {
-                       current->reset_due = ServerInstance->Time() + current->threshold;
-                       current->lines_in = 0;
-               }
+                       if (ServerInstance->Time() > current->reset_due)
+                       {
+                               current->reset_due = ServerInstance->Time() + current->MyClass->GetThreshold();
+                               current->lines_in = 0;
+                       }
 
-               if (++current->lines_in > current->flood && current->flood)
-               {
-                       ServerInstance->FloodQuitUser(current);
-                       return;
-               }
+                       if (++current->lines_in > current->MyClass->GetFlood() && current->MyClass->GetFlood())
+                       {
+                               ServerInstance->FloodQuitUser(current);
+                               return;
+                       }
 
-               if ((++floodlines > current->flood) && (current->flood != 0))
-               {
-                       ServerInstance->FloodQuitUser(current);
-                       return;
+                       if ((++floodlines > current->MyClass->GetFlood()) && (current->MyClass->GetFlood() != 0))
+                       {
+                               ServerInstance->FloodQuitUser(current);
+                               return;
+                       }
                }
 
                // use GetBuffer to copy single lines into the sanitized string
@@ -284,23 +287,16 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd)
                return true;
        }
 
-       if (!user)
-       {
-               /*
-                * before, we went and found the command even with no user.. seems nonsensical.
-                * I'm not entirely sure when we would be passed NULL, but let's handle it
-                * anyway, by dropping it like a hot potato. -- w00t
-                */
-               return true;
-       }
-
        /* find the command, check it exists */
        Commandable::iterator cm = cmdlist.find(command);
        
        if (cm == cmdlist.end())
        {
+               if (user->registered == REG_ALL)
+               {
+                       user->WriteServ("421 %s %s :Unknown command",user->nick,command.c_str());
+               }
                ServerInstance->stats->statsUnknown++;
-               user->WriteServ("421 %s %s :Unknown command",user->nick,command.c_str());
                return true;
        }
 
@@ -309,17 +305,15 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd)
        if (!user->ExemptFromPenalty)
        {
                user->IncreasePenalty(cm->second->Penalty);
-               ServerInstance->Log(DEBUG,"Penalty for %s is now incremented to %d (%d added on)", user->nick, user->Penalty, cm->second->Penalty);
                do_more = (user->Penalty < 10);
                if (!do_more)
-               {
                        user->OverPenalty = true;
-                       ServerInstance->Log(DEBUG,"User %s now OVER penalty of 10", user->nick);
-               }
        }
 
        /* activity resets the ping pending timer */
-       user->nping = ServerInstance->Time() + user->pingmax;
+       if (user->MyClass)
+               user->nping = ServerInstance->Time() + user->MyClass->GetPingTime();
+
        if (cm->second->flags_needed)
        {
                if (!user->IsModeSet(cm->second->flags_needed))
@@ -419,12 +413,10 @@ bool CommandParser::ProcessBuffer(std::string &buffer,User *user)
 
        if (buffer.length())
        {
-               if (!user->muted)
-               {
-                       ServerInstance->Log(DEBUG,"C[%d] I :%s %s",user->GetFd(), user->nick, buffer.c_str());
-                       return this->ProcessCommand(user,buffer);
-               }
+               ServerInstance->Log(DEBUG,"C[%d] I :%s %s",user->GetFd(), user->nick, buffer.c_str());
+               return this->ProcessCommand(user,buffer);
        }
+
        return true;
 }
 
@@ -508,13 +500,13 @@ bool CommandParser::ReloadCommand(const char* cmd, User* user)
        return false;
 }
 
-CmdResult cmd_reload::Handle(const char** parameters, int pcnt, User *user)
+CmdResult cmd_reload::Handle(const char** parameters, int /* pcnt */, User *user)
 {
        user->WriteServ("NOTICE %s :*** Reloading command '%s'",user->nick, parameters[0]);
        if (ServerInstance->Parser->ReloadCommand(parameters[0], user))
        {
                user->WriteServ("NOTICE %s :*** Successfully reloaded command '%s'", user->nick, parameters[0]);
-               ServerInstance->WriteOpers("*** RELOAD: %s reloaded the '%s' command.", user->nick, parameters[0]);
+               ServerInstance->SNO->WriteToSnoMask('A', "RELOAD: %s reloaded the '%s' command.", user->nick, parameters[0]);
                return CMD_SUCCESS;
        }
        else