]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Move OnStats from the core to a cross-module event.
authorPeter Powell <petpow@saberuk.com>
Sat, 7 Apr 2018 14:07:24 +0000 (15:07 +0100)
committerPeter Powell <petpow@saberuk.com>
Sun, 8 Apr 2018 15:54:27 +0000 (16:54 +0100)
Some core code still exists in the XLine system but this will be
replaced when the XLine system is replaced later.

17 files changed:
include/inspircd.h
include/modules.h
include/modules/stats.h
src/coremods/core_stats.cpp
src/coremods/core_whowas.cpp
src/modules.cpp
src/modules/extra/m_geoip.cpp
src/modules/m_cban.cpp
src/modules/m_dnsbl.cpp
src/modules/m_filter.cpp
src/modules/m_hideoper.cpp
src/modules/m_rline.cpp
src/modules/m_shun.cpp
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/main.h
src/modules/m_svshold.cpp
src/xline.cpp

index 95da70e54321a011ce8e68930afc35c8d352c923..0f73f192fe2e5540d8761b561d51dc91a90a80e3 100644 (file)
@@ -578,4 +578,3 @@ inline void stdalgo::culldeleter::operator()(classbase* item)
 
 #include "numericbuilder.h"
 #include "modules/whois.h"
-#include "modules/stats.h"
index a5e5461493e040b6c605189603584510f3adb772..72aa7b4d7fac034a628c23c3fc3db48955e1c496 100644 (file)
@@ -220,7 +220,7 @@ enum Implementation
        I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnLoadModule,
        I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite,
        I_OnRawMode, I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnCheckChannelBan, I_OnExtBanCheck,
-       I_OnStats, I_OnChangeLocalUserHost, I_OnPreTopicChange,
+       I_OnChangeLocalUserHost, I_OnPreTopicChange,
        I_OnPostTopicChange, I_OnPostConnect,
        I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete,
        I_OnPostOper, I_OnSetAway, I_OnPostCommand, I_OnPostJoin,
@@ -815,13 +815,6 @@ class CoreExport Module : public classbase, public usecountbase
         */
        virtual ModResult OnExtBanCheck(User* user, Channel* chan, char type);
 
-       /** Called on all /STATS commands
-        * This method is triggered for all /STATS use, including stats symbols handled by the core.
-        * @param stats Context of the /STATS request, contains requesting user, list of answer rows etc.
-        * @return 1 to block the /STATS from being processed by the core, 0 to allow it
-        */
-       virtual ModResult OnStats(Stats::Context& stats);
-
        /** Called whenever a change of a local users displayed host is attempted.
         * Return 1 to deny the host change, or 0 to allow it.
         * @param user The user whos host will be changed
index d2f6eabbb89f01d4f5c3781ac337d7a3b119ac08..e69070c9f65355dedbf41267faf2648323ccf88a 100644 (file)
 
 #pragma once
 
+#include "event.h"
+
 namespace Stats
 {
        class Context;
+       class EventListener;
        class Row;
 }
 
+class Stats::EventListener : public Events::ModuleEventListener
+{
+ public:
+       EventListener(Module* mod)
+               : ModuleEventListener(mod, "event/stats")
+       {
+       }
+
+       /** Called when the STATS command is executed.
+        * @param stats Context of the /STATS request, contains requesting user, list of answer rows etc.
+        * @return MOD_RES_DENY if the stats request has been fulfilled. Otherwise, MOD_RES_PASSTHRU.
+        */
+       virtual ModResult OnStats(Stats::Context& stats) = 0;
+};
+
 class Stats::Row : public Numeric::Numeric
 {
  public:
index d14aef15499952f2e2fa0808325f5b5cd0dc5c4f..5642cd52ee64be5c13a3e25bbb9532bf5e0a8bfd 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "inspircd.h"
 #include "xline.h"
+#include "modules/stats.h"
 
 #ifdef _WIN32
 #include <psapi.h>
  */
 class CommandStats : public Command
 {
+       Events::ModuleEventProvider statsevprov;
        void DoStats(Stats::Context& stats);
+
  public:
        /** Constructor for stats.
         */
-       CommandStats ( Module* parent) : Command(parent,"STATS",1,2) { allow_empty_last_param = false; syntax = "<stats-symbol> [<servername>]"; }
+       CommandStats(Module* Creator)
+               : Command(Creator, "STATS", 1, 2)
+               , statsevprov(Creator, "event/stats")
+       {
+               allow_empty_last_param = false;
+               syntax = "<stats-symbol> [<servername>]";
+       }
+
        /** Handle command.
         * @param parameters The parameters to the command
         * @param user The user issuing the command
@@ -82,7 +92,7 @@ void CommandStats::DoStats(Stats::Context& stats)
        }
 
        ModResult MOD_RESULT;
-       FIRST_MOD_RESULT(OnStats, MOD_RESULT, (stats));
+       FIRST_MOD_RESULT_CUSTOM(statsevprov, Stats::EventListener, OnStats, MOD_RESULT, (stats));
        if (MOD_RESULT == MOD_RES_DENY)
        {
                stats.AddRow(219, statschar, "End of /STATS report");
index f456a57db68dd8a877173166c900f7e63b57aea8..689340a8d79d84469aa13353b32eaa90bba096fa 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "inspircd.h"
 #include "commands/cmd_whowas.h"
+#include "modules/stats.h"
 
 enum
 {
@@ -260,12 +261,14 @@ WhoWas::Nick::~Nick()
        stdalgo::delete_all(entries);
 }
 
-class ModuleWhoWas : public Module
+class ModuleWhoWas : public Module, public Stats::EventListener
 {
        CommandWhowas cmd;
 
  public:
-       ModuleWhoWas() : cmd(this)
+       ModuleWhoWas()
+               : Stats::EventListener(this)
+               , cmd(this)
        {
        }
 
index ec793c64f43600a67ce1547309f34261670a9689..5f8439c44df854b678c9c03113542c7c5bed4531 100644 (file)
@@ -107,7 +107,6 @@ ModResult   Module::OnCheckLimit(User*, Channel*) { DetachEvent(I_OnCheckLimit); r
 ModResult      Module::OnCheckChannelBan(User*, Channel*) { DetachEvent(I_OnCheckChannelBan); return MOD_RES_PASSTHRU; }
 ModResult      Module::OnCheckBan(User*, Channel*, const std::string&) { DetachEvent(I_OnCheckBan); return MOD_RES_PASSTHRU; }
 ModResult      Module::OnExtBanCheck(User*, Channel*, char) { DetachEvent(I_OnExtBanCheck); return MOD_RES_PASSTHRU; }
-ModResult      Module::OnStats(Stats::Context&) { DetachEvent(I_OnStats); return MOD_RES_PASSTHRU; }
 ModResult      Module::OnChangeLocalUserHost(LocalUser*, const std::string&) { DetachEvent(I_OnChangeLocalUserHost); return MOD_RES_PASSTHRU; }
 ModResult      Module::OnChangeLocalUserGECOS(LocalUser*, const std::string&) { DetachEvent(I_OnChangeLocalUserGECOS); return MOD_RES_PASSTHRU; }
 ModResult      Module::OnPreTopicChange(User*, Channel*, const std::string&) { DetachEvent(I_OnPreTopicChange); return MOD_RES_PASSTHRU; }
index 35efc8d70a4187ad5c80537587aeca7fbe7bd9af..b6b0c3fa19ed4cd4e80416b01872a849d6f69c9e 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "inspircd.h"
 #include "xline.h"
+#include "modules/stats.h"
 
 // Fix warnings about the use of commas at end of enumerator lists on C++03.
 #if defined __clang__
@@ -47,7 +48,7 @@ enum
        RPL_WHOISCOUNTRY = 344
 };
 
-class ModuleGeoIP : public Module, public Whois::EventListener
+class ModuleGeoIP : public Module, public Stats::EventListener, public Whois::EventListener
 {
        StringExtItem ext;
        bool extban;
@@ -65,7 +66,8 @@ class ModuleGeoIP : public Module, public Whois::EventListener
 
  public:
        ModuleGeoIP()
-               : Whois::EventListener(this)
+               : Stats::EventListener(this)
+               , Whois::EventListener(this)
                , ext("geoip_cc", ExtensionItem::EXT_USER, this)
                , extban(true)
                , gi(NULL)
index 54b1e39eed66e65761b1224108f34339677de96c..7235a8befa3d186aca0d82882b7bddf8121d003b 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "inspircd.h"
 #include "xline.h"
+#include "modules/stats.h"
 
 /** Holds a CBAN item
  */
@@ -140,13 +141,15 @@ class CommandCBan : public Command
        }
 };
 
-class ModuleCBan : public Module
+class ModuleCBan : public Module, public Stats::EventListener
 {
        CommandCBan mycommand;
        CBanFactory f;
 
  public:
-       ModuleCBan() : mycommand(this)
+       ModuleCBan()
+               : Stats::EventListener(this)
+               , mycommand(this)
        {
        }
 
index 732717ff3dc08ea7704f956f41a0e7961c45d94f..ab24873ce3225326d37c6ada9a2e578c53875814 100644 (file)
@@ -24,6 +24,7 @@
 #include "inspircd.h"
 #include "xline.h"
 #include "modules/dns.h"
+#include "modules/stats.h"
 
 /* Class holding data for a single entry */
 class DNSBLConfEntry : public refcountbase
@@ -220,7 +221,7 @@ class DNSBLResolver : public DNS::Request
        }
 };
 
-class ModuleDNSBL : public Module
+class ModuleDNSBL : public Module, public Stats::EventListener
 {
        std::vector<reference<DNSBLConfEntry> > DNSBLConfEntries;
        dynamic_reference<DNS::Manager> DNS;
@@ -247,7 +248,8 @@ class ModuleDNSBL : public Module
        }
  public:
        ModuleDNSBL()
-               : DNS(this, "DNS")
+               : Stats::EventListener(this)
+               , DNS(this, "DNS")
                , nameExt("dnsbl_match", ExtensionItem::EXT_USER, this)
                , countExt("dnsbl_pending", ExtensionItem::EXT_USER, this)
        {
index 8ad692971179d78043747cf01e2f85dbbf098244..d3d3ef2185f30c041defb81fce553e3ce23d5e29 100644 (file)
@@ -25,6 +25,7 @@
 #include "modules/regex.h"
 #include "modules/server.h"
 #include "modules/shun.h"
+#include "modules/stats.h"
 
 enum FilterFlags
 {
@@ -160,7 +161,7 @@ class CommandFilter : public Command
        }
 };
 
-class ModuleFilter : public Module, public ServerEventListener
+class ModuleFilter : public Module, public ServerEventListener, public Stats::EventListener
 {
        typedef insp::flat_set<std::string, irc::insensitive_swo> ExemptTargetSet;
 
@@ -302,6 +303,7 @@ bool ModuleFilter::AppliesToMe(User* user, FilterResult* filter, int iflags)
 
 ModuleFilter::ModuleFilter()
        : ServerEventListener(this)
+       , Stats::EventListener(this)
        , initing(true)
        , filtcommand(this)
        , RegexEngine(this, "regex")
index 2e0b388cf7eeec0630410a5f4fea687165b23882..6ecfc6074fd7fe6c86fdedd015d5605e9c5ab392 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "inspircd.h"
+#include "modules/stats.h"
 
 /** Handles user mode +H
  */
@@ -48,13 +49,14 @@ class HideOper : public SimpleUserModeHandler
        }
 };
 
-class ModuleHideOper : public Module, public Whois::LineEventListener
+class ModuleHideOper : public Module, public Stats::EventListener, public Whois::LineEventListener
 {
        HideOper hm;
        bool active;
  public:
        ModuleHideOper()
-               : Whois::LineEventListener(this)
+               : Stats::EventListener(this)
+               , Whois::LineEventListener(this)
                , hm(this)
                , active(false)
        {
index 9bb1167f51810caad7d410989dc97e616a794d79..e3a84397f5657b7842e8ee8be7084c919be75113 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "inspircd.h"
 #include "modules/regex.h"
+#include "modules/stats.h"
 #include "xline.h"
 
 static bool ZlineOnMatch = false;
@@ -206,7 +207,7 @@ class CommandRLine : public Command
        }
 };
 
-class ModuleRLine : public Module
+class ModuleRLine : public Module, public Stats::EventListener
 {
        dynamic_reference<RegexFactory> rxfactory;
        RLineFactory f;
@@ -217,7 +218,10 @@ class ModuleRLine : public Module
 
  public:
        ModuleRLine()
-               : rxfactory(this, "regex"), f(rxfactory), r(this, f)
+               : Stats::EventListener(this)
+               , rxfactory(this, "regex")
+               , f(rxfactory)
+               , r(this, f)
                , initing(true)
        {
        }
index 5b0b42cae7d58c27d996c6d09b9f97daf0725e39..92c0b0bd0d36b1a2f01e042d8af254aa734c8d6b 100644 (file)
@@ -23,6 +23,7 @@
 #include "inspircd.h"
 #include "xline.h"
 #include "modules/shun.h"
+#include "modules/stats.h"
 
 
 /** An XLineFactory specialized to generate shun pointers
@@ -133,7 +134,7 @@ class CommandShun : public Command
        }
 };
 
-class ModuleShun : public Module
+class ModuleShun : public Module, public Stats::EventListener
 {
        CommandShun cmd;
        ShunFactory f;
@@ -142,7 +143,9 @@ class ModuleShun : public Module
        bool affectopers;
 
  public:
-       ModuleShun() : cmd(this)
+       ModuleShun()
+               : Stats::EventListener(this)
+               , cmd(this)
        {
        }
 
index 1a77237bd6d437686d6c0807774eb132306537bb..2fd578698e2151f722117c43080d7a65b5a59858 100644 (file)
 #include "translate.h"
 
 ModuleSpanningTree::ModuleSpanningTree()
-       : rconnect(this), rsquit(this), map(this)
+       : Stats::EventListener(this)
+       , rconnect(this)
+       , rsquit(this)
+       , map(this)
        , commands(this)
        , currmembid(0)
        , eventprov(this, "event/server")
index 4eefb01a0698149d83134738a0c9889d0baada7a..5add15e8a98f8385f165d3d403d9263fa51d1893 100644 (file)
@@ -26,6 +26,7 @@
 #include "inspircd.h"
 #include "event.h"
 #include "modules/dns.h"
+#include "modules/stats.h"
 #include "servercommand.h"
 #include "commands.h"
 #include "protocolinterface.h"
@@ -52,7 +53,7 @@ class Autoconnect;
 
 /** This is the main class for the spanningtree module
  */
-class ModuleSpanningTree : public Module
+class ModuleSpanningTree : public Module, public Stats::EventListener
 {
        /** Client to server commands, registered in the core
         */
index 1ba16f3f401eccb233eb56bb8c154ee6b776e65c..481a1aaba4643d00c7c81fe3cc627f7db155677c 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "inspircd.h"
 #include "xline.h"
+#include "modules/stats.h"
 
 namespace
 {
@@ -161,14 +162,16 @@ class CommandSvshold : public Command
        }
 };
 
-class ModuleSVSHold : public Module
+class ModuleSVSHold : public Module, public Stats::EventListener
 {
        CommandSvshold cmd;
        SVSHoldFactory s;
 
 
  public:
-       ModuleSVSHold() : cmd(this)
+       ModuleSVSHold()
+               : Stats::EventListener(this)
+               , cmd(this)
        {
        }
 
index 8d4c822aab715bc43e5c5c7ade70dde7bbe7863a..dfd7e290301040afb1d8aa3f5ab203d017aefc51 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "inspircd.h"
 #include "xline.h"
+#include "modules/stats.h"
 
 /** An XLineFactory specialized to generate GLine* pointers
  */