X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_operlog.cpp;h=edb9109e89f246d0cde5089655c1ae7279d0c7c6;hb=68211809ee3111bdc9609fbd46dc3c875fbb5ea6;hp=cc533dbf5de7cb54e211fe85c77d205279f1ffd5;hpb=46a39046196f55b52336e19662bb7bac85b731ac;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_operlog.cpp b/src/modules/m_operlog.cpp index cc533dbf5..edb9109e8 100644 --- a/src/modules/m_operlog.cpp +++ b/src/modules/m_operlog.cpp @@ -25,13 +25,15 @@ class ModuleOperLog : public Module { - private: + bool tosnomask; public: - ModuleOperLog() { - - Implementation eventlist[] = { I_OnPreCommand, I_On005Numeric }; - ServerInstance->Modules->Attach(eventlist, this, 2); + void init() + { + Implementation eventlist[] = { I_OnPreCommand, I_On005Numeric, I_OnRehash }; + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); + ServerInstance->SNO->EnableSnomask('r', "OPERLOG"); + OnRehash(NULL); } virtual ~ModuleOperLog() @@ -43,6 +45,10 @@ class ModuleOperLog : public Module return Version("A module which logs all oper commands to the ircd log at default loglevel.", VF_VENDOR); } + void OnRehash(User* user) + { + tosnomask = ServerInstance->Config->ConfValue("operlog")->getBool("tosnomask", false); + } virtual ModResult OnPreCommand(std::string &command, std::vector ¶meters, LocalUser *user, bool validated, const std::string &original_line) { @@ -54,7 +60,15 @@ class ModuleOperLog : public Module { Command* thiscommand = ServerInstance->Parser->GetHandler(command); if ((thiscommand) && (thiscommand->flags_needed == 'o')) - ServerInstance->Logs->Log("m_operlog",DEFAULT,"OPERLOG: [%s!%s@%s] %s %s",user->nick.c_str(), user->ident.c_str(), user->host.c_str(), command.c_str(), parameters.empty() ? "" : irc::stringjoiner(" ", parameters, 0, parameters.size() - 1).GetJoined().c_str()); + { + std::string line; + if (!parameters.empty()) + line = irc::stringjoiner(" ", parameters, 0, parameters.size() - 1).GetJoined(); + std::string msg = "[" + user->GetFullRealHost() + "] " + command + " " + line; + ServerInstance->Logs->Log("m_operlog", DEFAULT, "OPERLOG: " + msg); + if (tosnomask) + ServerInstance->SNO->WriteGlobalSno('r', msg); + } } return MOD_RES_PASSTHRU;