]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_stats.cpp
Add the Numerics::CannotSendTo class and switch stuff to use it.
[user/henk/code/inspircd.git] / src / coremods / core_stats.cpp
index bb20dd7612ab470cd9bd3b29dd1807222b8ddfff..4b30fa5b4ac7a82d046712c03f0429cdfd436b8d 100644 (file)
@@ -1,9 +1,16 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2018 Puck Meerburg <puck@puckipedia.com>
+ *   Copyright (C) 2018 Dylan Frank <b00mx0r@aureus.pw>
+ *   Copyright (C) 2016-2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012-2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2012 ChrisTX <xpipe@hotmail.de>
+ *   Copyright (C) 2012 Adam <Adam@anope.org>
  *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
- *   Copyright (C) 2007-2008 Craig Edwards <craigedwards@brainbox.cc>
- *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2006, 2008, 2010 Craig Edwards <brain@inspircd.org>
  *
  * 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
@@ -36,14 +43,15 @@ class CommandStats : public Command
        void DoStats(Stats::Context& stats);
 
  public:
-       /** Constructor for stats.
-        */
+       /** STATS characters which non-opers can request. */
+       std::string userstats;
+
        CommandStats(Module* Creator)
                : Command(Creator, "STATS", 1, 2)
                , statsevprov(Creator, "event/stats")
        {
                allow_empty_last_param = false;
-               syntax = "<stats-symbol> [<servername>]";
+               syntax = "<symbol> [<servername>]";
        }
 
        /** Handle command.
@@ -77,7 +85,7 @@ void CommandStats::DoStats(Stats::Context& stats)
        User* const user = stats.GetSource();
        const char statschar = stats.GetSymbol();
 
-       bool isPublic = ServerInstance->Config->UserStats.find(statschar) != std::string::npos;
+       bool isPublic = userstats.find(statschar) != std::string::npos;
        bool isRemoteOper = IS_REMOTE(user) && (user->IsOper());
        bool isLocalOperWithPrivs = IS_LOCAL(user) && user->HasPrivPermission("servers/auspex");
 
@@ -187,19 +195,19 @@ void CommandStats::DoStats(Stats::Context& stats)
                break;
 
                case 'k':
-                       ServerInstance->XLines->InvokeStats("K",216,stats);
+                       ServerInstance->XLines->InvokeStats("K", stats);
                break;
                case 'g':
-                       ServerInstance->XLines->InvokeStats("G",223,stats);
+                       ServerInstance->XLines->InvokeStats("G", stats);
                break;
                case 'q':
-                       ServerInstance->XLines->InvokeStats("Q",217,stats);
+                       ServerInstance->XLines->InvokeStats("Q", stats);
                break;
                case 'Z':
-                       ServerInstance->XLines->InvokeStats("Z",223,stats);
+                       ServerInstance->XLines->InvokeStats("Z", stats);
                break;
                case 'e':
-                       ServerInstance->XLines->InvokeStats("E",223,stats);
+                       ServerInstance->XLines->InvokeStats("E", stats);
                break;
                case 'E':
                {
@@ -377,7 +385,7 @@ void CommandStats::DoStats(Stats::Context& stats)
 
 CmdResult CommandStats::Handle(User* user, const Params& parameters)
 {
-       if (parameters.size() > 1 && parameters[1] != ServerInstance->Config->ServerName)
+       if (parameters.size() > 1 && !irc::equals(parameters[1], ServerInstance->Config->ServerName))
        {
                // Give extra penalty if a non-oper does /STATS <remoteserver>
                LocalUser* localuser = IS_LOCAL(user);
@@ -397,4 +405,27 @@ CmdResult CommandStats::Handle(User* user, const Params& parameters)
        return CMD_SUCCESS;
 }
 
-COMMAND_INIT(CommandStats)
+class CoreModStats : public Module
+{
+ private:
+       CommandStats cmd;
+
+ public:
+       CoreModStats()
+               : cmd(this)
+       {
+       }
+
+       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
+       {
+               ConfigTag* security = ServerInstance->Config->ConfValue("security");
+               cmd.userstats = security->getString("userstats");
+       }
+
+       Version GetVersion() CXX11_OVERRIDE
+       {
+               return Version("Provides the STATS command", VF_CORE | VF_VENDOR);
+       }
+};
+
+MODULE_INIT(CoreModStats)