X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcommand_parse.cpp;h=f07a4ffd78aabf50676815e8e90e8d4f92acc21b;hb=4487dde76ffbdb21e7dc319b3b87d09c3cf60d8c;hp=9a525dd5b360148c8a869ba3948799bb01bd7205;hpb=2c25d4a34428088b9407be14740041346500eb5f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 9a525dd5b..f07a4ffd7 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -25,24 +25,6 @@ #include #endif -bool InspIRCd::ULine(const char* server) -{ - if (!server) - return false; - if (!*server) - return true; - - return (Config->ulines.find(server) != Config->ulines.end()); -} - -bool InspIRCd::SilentULine(const char* server) -{ - std::map::iterator n = Config->ulines.find(server); - if (n != Config->ulines.end()) - return n->second; - else return false; -} - int InspIRCd::OperPassCompare(const char* data,const char* input, int tagnumber) { int MOD_RESULT = 0; @@ -54,11 +36,6 @@ int InspIRCd::OperPassCompare(const char* data,const char* input, int tagnumber) return strcmp(data,input); } -std::string InspIRCd::TimeString(time_t curtime) -{ - return std::string(ctime(&curtime),24); -} - /* LoopCall is used to call a command classes handler repeatedly based on the contents of a comma seperated list. * There are two overriden versions of this method, one of which takes two potential lists and the other takes one. * We need a version which takes two potential lists for JOIN, because a JOIN may contain two lists of items at once, @@ -267,72 +244,80 @@ void CommandParser::ProcessCommand(User *user, std::string &cmd) return; } + 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; + } + + /* find the command, check it exists */ Commandable::iterator cm = cmdlist.find(command); - if (cm != cmdlist.end()) + if (cm == cmdlist.end()) + { + ServerInstance->stats->statsUnknown++; + user->WriteServ("421 %s %s :Unknown command",user->nick,command.c_str()); + return; + } + + /* activity resets the ping pending timer */ + user->nping = ServerInstance->Time() + user->pingmax; + if (cm->second->flags_needed) { - if (user) + if (!user->IsModeSet(cm->second->flags_needed)) { - /* activity resets the ping pending timer */ - user->nping = ServerInstance->Time() + user->pingmax; - if (cm->second->flags_needed) - { - if (!user->IsModeSet(cm->second->flags_needed)) - { - user->WriteServ("481 %s :Permission Denied - You do not have the required operator privileges",user->nick); - return; - } - if (!user->HasPermission(command)) - { - user->WriteServ("481 %s :Permission Denied - Oper type %s does not have access to command %s",user->nick,user->oper,command.c_str()); - return; - } - } - if ((user->registered == REG_ALL) && (!IS_OPER(user)) && (cm->second->IsDisabled())) - { - /* command is disabled! */ - user->WriteServ("421 %s %s :This command has been disabled.",user->nick,command.c_str()); - ServerInstance->SNO->WriteToSnoMask('d', "%s denied for %s (%s@%s)", - command.c_str(), user->nick, user->ident, user->host); - return; - } - if (items < cm->second->min_params) - { - user->WriteServ("461 %s %s :Not enough parameters.", user->nick, command.c_str()); - if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (cm->second->syntax.length())) - user->WriteServ("304 %s :SYNTAX %s %s", user->nick, cm->second->command.c_str(), cm->second->syntax.c_str()); - return; - } - if ((user->registered == REG_ALL) || (cm->second->WorksBeforeReg())) - { - /* ikky /stats counters */ - cm->second->use_count++; - cm->second->total_bytes += cmd.length(); - - int MOD_RESULT = 0; - FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,true,cmd)); - if (MOD_RESULT == 1) - return; - - /* - * WARNING: be careful, the user may be deleted soon - */ - CmdResult result = cm->second->Handle(command_p,items,user); - - FOREACH_MOD(I_OnPostCommand,OnPostCommand(command, command_p, items, user, result,cmd)); - return; - } - else - { - user->WriteServ("451 %s :You have not registered",command.c_str()); - return; - } + user->WriteServ("481 %s :Permission Denied - You do not have the required operator privileges",user->nick); + return; + } + if (!user->HasPermission(command)) + { + user->WriteServ("481 %s :Permission Denied - Oper type %s does not have access to command %s",user->nick,user->oper,command.c_str()); + return; } } - else if (user) + if ((user->registered == REG_ALL) && (!IS_OPER(user)) && (cm->second->IsDisabled())) { - ServerInstance->stats->statsUnknown++; - user->WriteServ("421 %s %s :Unknown command",user->nick,command.c_str()); + /* command is disabled! */ + user->WriteServ("421 %s %s :This command has been disabled.",user->nick,command.c_str()); + ServerInstance->SNO->WriteToSnoMask('d', "%s denied for %s (%s@%s)", + command.c_str(), user->nick, user->ident, user->host); + return; + } + if (items < cm->second->min_params) + { + user->WriteServ("461 %s %s :Not enough parameters.", user->nick, command.c_str()); + if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (cm->second->syntax.length())) + user->WriteServ("304 %s :SYNTAX %s %s", user->nick, cm->second->command.c_str(), cm->second->syntax.c_str()); + return; + } + if ((user->registered != REG_ALL) && (!cm->second->WorksBeforeReg())) + { + user->WriteServ("451 %s :You have not registered",command.c_str()); + return; + } + else + { + /* passed all checks.. first, do the (ugly) stats counters. */ + cm->second->use_count++; + cm->second->total_bytes += cmd.length(); + + /* module calls too */ + int MOD_RESULT = 0; + FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,true,cmd)); + if (MOD_RESULT == 1) + return; + + /* + * WARNING: be careful, the user may be deleted soon + */ + CmdResult result = cm->second->Handle(command_p,items,user); + + FOREACH_MOD(I_OnPostCommand,OnPostCommand(command, command_p, items, user, result,cmd)); + return; } } @@ -567,24 +552,20 @@ int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, st User* user = NULL; std::string item; int translations = 0; + dest.clear(); switch (to) { case TR_NICK: /* Translate single nickname */ - ServerInstance->Log(DEBUG,"TR_NICK"); user = ServerInstance->FindNick(source); if (user) { - ServerInstance->Log(DEBUG,"Managed UUID"); dest = user->uuid; translations++; } else - { - ServerInstance->Log(DEBUG,"Had to use source.. (%s)", source.c_str()); dest = source; - } break; case TR_NICKLIST: { @@ -599,7 +580,7 @@ int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, st translations++; } else - dest.append(source); + dest.append(item); dest.append(","); } if (!dest.empty()) @@ -619,7 +600,7 @@ int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, st translations++; } else - dest.append(source); + dest.append(item); dest.append(" "); } if (!dest.empty())