]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_rline.cpp
Fix memory leak and invalid vtable location on unload of m_sslinfo
[user/henk/code/inspircd.git] / src / modules / m_rline.cpp
index f6047704e7d429642f7576b476167685f69d91ec..b2ddd798df9c0f076dc435f187f0baf3cedb8e1e 100644 (file)
@@ -3,7 +3,7 @@
  *       +------------------------------------+
  *
  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
@@ -32,7 +32,8 @@ class RLine : public XLine
         * @param regex Pattern to match with
         * @
         */
-       RLine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char* regexs) : XLine(Instance, s_time, d, src, re, "R")
+       RLine(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string regexs)
+               : XLine(Instance, s_time, d, src, re, "R")
        {
                matchtext = regexs;
 
@@ -57,6 +58,9 @@ class RLine : public XLine
 
        bool Matches(User *u)
        {
+               if (u->exempt)
+                       return false;
+
                std::string compare = u->nick + "!" + u->ident + "@" + u->host + " " + u->fullname;
                return regex->Matches(compare);
        }
@@ -73,7 +77,8 @@ class RLine : public XLine
 
        void DisplayExpiry()
        {
-               ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed R-Line %s (set by %s %ld seconds ago)", this->matchtext.c_str(), this->source, this->duration);
+               ServerInstance->SNO->WriteToSnoMask('x',"Removing expired R-Line %s (set by %s %ld seconds ago)",
+                       this->matchtext.c_str(), this->source.c_str(), (long int)(ServerInstance->Time() - this->set_time));
        }
 
        const char* Displayable()
@@ -98,7 +103,7 @@ class RLineFactory : public XLineFactory
 
        /** Generate a RLine
         */
-       XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask)
+       XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask)
        {
                return new RLine(ServerInstance, set_time, duration, source, reason, xline_specific_mask);
        }
@@ -116,9 +121,8 @@ class CommandRLine : public Command
        std::string rxengine;
 
  public:
-       CommandRLine (InspIRCd* Instance) : Command(Instance,"RLINE", "o", 1, 3)
+       CommandRLine (InspIRCd* Instance, Module* Creator) : Command(Instance, Creator,"RLINE", "o", 1, 3)
        {
-               this->source = "m_rline.so";
                this->syntax = "<regex> [<rline-duration>] :<reason>";
        }
 
@@ -183,25 +187,21 @@ class CommandRLine : public Command
 class ModuleRLine : public Module
 {
  private:
-       CommandRLine *r;
-       RLineFactory *f;
+       CommandRLine r;
+       RLineFactory f;
        bool MatchOnNickChange;
        std::string RegexEngine;
 
  public:
-       ModuleRLine(InspIRCd* Me) : Module(Me)
+       ModuleRLine(InspIRCd* Me) : Module(Me), r(Me, this), f(Me)
        {
                mymodule = this;
-               OnRehash(NULL, "");
+               OnRehash(NULL);
 
                Me->Modules->UseInterface("RegularExpression");
 
-               // Create a new command
-               r = new CommandRLine(ServerInstance);
-               ServerInstance->AddCommand(r);
-
-               f = new RLineFactory(ServerInstance);
-               ServerInstance->XLines->RegisterFactory(f);
+               ServerInstance->AddCommand(&r);
+               ServerInstance->XLines->RegisterFactory(&f);
 
                Implementation eventlist[] = { I_OnUserConnect, I_OnRehash, I_OnUserPostNick, I_OnLoadModule, I_OnStats };
                ServerInstance->Modules->Attach(eventlist, this, 5);
@@ -212,7 +212,7 @@ class ModuleRLine : public Module
        {
                ServerInstance->Modules->DoneWithInterface("RegularExpression");
                ServerInstance->XLines->DelAll("R");
-               ServerInstance->XLines->UnregisterFactory(f);
+               ServerInstance->XLines->UnregisterFactory(&f);
        }
 
        virtual Version GetVersion()
@@ -232,7 +232,7 @@ class ModuleRLine : public Module
                }
        }
 
-       virtual void OnRehash(User *user, const std::string &parameter)
+       virtual void OnRehash(User *user)
        {
                ConfigReader Conf(ServerInstance);
 
@@ -267,13 +267,13 @@ class ModuleRLine : public Module
                }
        }
 
-       virtual int OnStats(char symbol, User* user, string_list &results)
+       virtual ModResult OnStats(char symbol, User* user, string_list &results)
        {
                if (symbol != 'R')
-                       return 0;
+                       return MOD_RES_PASSTHRU;
 
                ServerInstance->XLines->InvokeStats("R", 223, user, results);
-               return 1;
+               return MOD_RES_DENY;
        }
 
        virtual void OnLoadModule(Module* mod, const std::string& name)