2012-04-19 20:58:29 +02:00
|
|
|
/*
|
|
|
|
* InspIRCd -- Internet Relay Chat Daemon
|
2007-07-16 17:30:04 +00:00
|
|
|
*
|
2020-04-24 10:23:47 +01:00
|
|
|
* Copyright (C) 2013, 2018-2020 Sadie Powell <sadie@witchery.services>
|
2020-01-11 22:02:47 +00:00
|
|
|
* Copyright (C) 2012-2014 Attila Molnar <attilamolnar@hush.com>
|
|
|
|
* Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
|
|
|
|
* Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
|
2012-04-19 20:58:29 +02:00
|
|
|
* Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
|
2020-01-11 22:02:47 +00:00
|
|
|
* Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
|
|
|
|
* Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
|
2007-07-16 17:30:04 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* This file is part of InspIRCd. InspIRCd is free software: you can
|
|
|
|
* redistribute it and/or modify it under the terms of the GNU General Public
|
|
|
|
* License as published by the Free Software Foundation, version 2.
|
2007-07-16 17:30:04 +00:00
|
|
|
*
|
2012-04-19 20:58:29 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2007-07-16 17:30:04 +00:00
|
|
|
*/
|
|
|
|
|
2012-04-19 20:58:29 +02:00
|
|
|
|
2007-08-27 14:49:08 +00:00
|
|
|
#include "inspircd.h"
|
2020-01-05 14:41:06 +00:00
|
|
|
#include "modules/isupport.h"
|
2007-07-16 17:30:04 +00:00
|
|
|
|
2020-01-05 14:41:06 +00:00
|
|
|
class ModuleOperLog
|
|
|
|
: public Module
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
2020-01-05 14:41:06 +00:00
|
|
|
private:
|
2012-10-12 23:32:35 +02:00
|
|
|
bool tosnomask;
|
2008-06-11 11:35:23 +00:00
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
public:
|
2020-01-05 14:41:06 +00:00
|
|
|
ModuleOperLog()
|
2020-04-11 14:00:48 +01:00
|
|
|
: Module(VF_VENDOR, "Allows the server administrator to make the server log when a server operator-only command is executed.")
|
2020-01-05 14:41:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-25 02:52:11 +00:00
|
|
|
void ReadConfig(ConfigStatus& status) override
|
2012-10-12 23:32:35 +02:00
|
|
|
{
|
|
|
|
tosnomask = ServerInstance->Config->ConfValue("operlog")->getBool("tosnomask", false);
|
|
|
|
}
|
2007-07-16 17:30:04 +00:00
|
|
|
|
2019-01-25 02:52:11 +00:00
|
|
|
ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) override
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
|
|
|
/* If the command doesnt appear to be valid, we dont want to mess with it. */
|
|
|
|
if (!validated)
|
2009-09-02 00:49:36 +00:00
|
|
|
return MOD_RES_PASSTHRU;
|
2008-06-11 11:35:23 +00:00
|
|
|
|
2019-04-19 09:30:45 +01:00
|
|
|
if ((user->IsOper()) && (user->HasCommandPermission(command)))
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
2014-06-13 15:45:55 +02:00
|
|
|
Command* thiscommand = ServerInstance->Parser.GetHandler(command);
|
2020-04-14 21:30:50 +01:00
|
|
|
if ((thiscommand) && (thiscommand->access_needed == CmdAccess::OPERATOR))
|
2012-09-30 01:10:57 +02:00
|
|
|
{
|
2018-07-26 21:23:45 +01:00
|
|
|
std::string msg = "[" + user->GetFullRealHost() + "] " + command + " " + stdalgo::string::join(parameters);
|
2012-10-12 23:32:35 +02:00
|
|
|
if (tosnomask)
|
2021-09-23 00:28:05 +01:00
|
|
|
ServerInstance->SNO.WriteGlobalSno('o', msg);
|
2020-04-12 14:52:52 +01:00
|
|
|
else
|
2020-04-14 19:57:10 +01:00
|
|
|
ServerInstance->Logs.Log(MODNAME, LOG_DEFAULT, msg);
|
2012-09-30 01:10:57 +02:00
|
|
|
}
|
2007-07-16 17:30:04 +00:00
|
|
|
}
|
|
|
|
|
2009-09-02 00:49:36 +00:00
|
|
|
return MOD_RES_PASSTHRU;
|
2007-07-16 17:30:04 +00:00
|
|
|
}
|
|
|
|
};
|
2008-06-11 11:35:23 +00:00
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
MODULE_INIT(ModuleOperLog)
|