]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_oper/cmd_oper.cpp
core_privmsg: respect the exemption list when sending $* messages.
[user/henk/code/inspircd.git] / src / coremods / core_oper / cmd_oper.cpp
index bd7a35060e8e82a7c10543c322d08cc9bc825ef2..8c3c86adc4df74d2af589ad3830b3e67dc9c4066 100644 (file)
 
 
 #include "inspircd.h"
+#include "core_oper.h"
 
-/** Handle /OPER.
- */
-class CommandOper : public SplitCommand
+CommandOper::CommandOper(Module* parent)
+       : SplitCommand(parent, "OPER", 2, 2)
 {
- public:
-       /** Constructor for oper.
-        */
-       CommandOper ( Module* parent) : SplitCommand(parent,"OPER",2,2) { syntax = "<username> <password>"; }
-       /** Handle command.
-        * @param parameters The parameters to the command
-        * @param user The user issuing the command
-        * @return A value from CmdResult to indicate command success or failure.
-        */
-       CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser *user);
-};
+       syntax = "<username> <password>";
+}
 
-CmdResult CommandOper::HandleLocal(const std::vector<std::string>& parameters, LocalUser *user)
+CmdResult CommandOper::HandleLocal(LocalUser* user, const Params& parameters)
 {
        bool match_login = false;
        bool match_pass = false;
        bool match_hosts = false;
 
-       const std::string userHost = user->ident + "@" + user->host;
+       const std::string userHost = user->ident + "@" + user->GetRealHost();
        const std::string userIP = user->ident + "@" + user->GetIPString();
 
-       OperIndex::iterator i = ServerInstance->Config->oper_blocks.find(parameters[0]);
+       ServerConfig::OperIndex::const_iterator i = ServerInstance->Config->oper_blocks.find(parameters[0]);
        if (i != ServerInstance->Config->oper_blocks.end())
        {
                OperInfo* ifo = i->second;
@@ -72,12 +63,9 @@ CmdResult CommandOper::HandleLocal(const std::vector<std::string>& parameters, L
                fields.append("hosts");
 
        // tell them they suck, and lag them up to help prevent brute-force attacks
-       user->WriteNumeric(ERR_NOOPERHOST, ":Invalid oper credentials");
+       user->WriteNumeric(ERR_NOOPERHOST, "Invalid oper credentials");
        user->CommandFloodPenalty += 10000;
 
        ServerInstance->SNO->WriteGlobalSno('o', "WARNING! Failed oper attempt by %s using login '%s': The following fields do not match: %s", user->GetFullRealHost().c_str(), parameters[0].c_str(), fields.c_str());
-       ServerInstance->Logs->Log("OPER", LOG_DEFAULT, "OPER: Failed oper attempt by %s using login '%s': The following fields did not match: %s", user->GetFullRealHost().c_str(), parameters[0].c_str(), fields.c_str());
        return CMD_FAILURE;
 }
-
-COMMAND_INIT(CommandOper)