]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_dccallow.cpp
Replace std::deque with std::vector in spanningtree and related modules
[user/henk/code/inspircd.git] / src / modules / m_dccallow.cpp
index 7edcdfeb08b99394538952f2e01750e1555388d5..97f0d2f13d916910e73b5f1eca9e80cde070d5cf 100644 (file)
@@ -2,8 +2,8 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
@@ -135,7 +135,7 @@ class CommandDccallow : public Command
                                                user->WriteNumeric(996, "%s %s :You cannot add yourself to your own DCCALLOW list!", user->nick.c_str(), user->nick.c_str());
                                                return CMD_FAILURE;
                                        }
-                                       
+
                                        if (!user->GetExt("dccallow_list", dl))
                                        {
                                                dl = new dccallowlist;
@@ -143,7 +143,7 @@ class CommandDccallow : public Command
                                                // add this user to the userlist
                                                ul.push_back(user);
                                        }
-                                       
+
                                        for (dccallowlist::const_iterator k = dl->begin(); k != dl->end(); ++k)
                                        {
                                                if (k->nickname == target->nick)
@@ -244,25 +244,25 @@ class CommandDccallow : public Command
 
 class ModuleDCCAllow : public Module
 {
-       CommandDccallow* mycommand;
+       CommandDccallow cmd;
  public:
 
        ModuleDCCAllow(InspIRCd* Me)
-               : Module(Me)
+               : Module(Me), cmd(Me)
        {
                Conf = new ConfigReader(ServerInstance);
-               mycommand = new CommandDccallow(ServerInstance);
-               ServerInstance->AddCommand(mycommand);
+               ServerInstance->AddCommand(&cmd);
                ReadFileConf();
                Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserQuit, I_OnUserPreNick, I_OnRehash };
                ServerInstance->Modules->Attach(eventlist, this, 5);
        }
 
 
-       virtual void OnRehash(User* user, const std::string &parameter)
+       virtual void OnRehash(User* user)
        {
                delete Conf;
                Conf = new ConfigReader(ServerInstance);
+               ReadFileConf();
        }
 
        virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
@@ -340,23 +340,26 @@ class ModuleDCCAllow : public Module
                                                std::string defaultaction = Conf->ReadValue("dccallow", "action", 0);
                                                std::string filename = tokens[2];
 
-                                               if (defaultaction == "allow")
-                                                       return 0;
-
+                                               bool found = false;
                                                for (unsigned int i = 0; i < bfl.size(); i++)
                                                {
                                                        if (InspIRCd::Match(filename, bfl[i].filemask, ascii_case_insensitive_map))
                                                        {
+                                                               /* We have a matching badfile entry, override whatever the default action is */
                                                                if (bfl[i].action == "allow")
                                                                        return 0;
-                                                       }
-                                                       else
-                                                       {
-                                                               if (defaultaction == "allow")
-                                                                       return 0;
+                                                               else
+                                                               {
+                                                                       found = true;
+                                                                       break;
+                                                               }
                                                        }
                                                }
-                                               
+
+                                               /* only follow the default action if no badfile matches were found above */
+                                               if ((!found) && (defaultaction == "allow"))
+                                                       return 0;
+
                                                user->WriteServ("NOTICE %s :The user %s is not accepting DCC SENDs from you. Your file %s was not sent.", user->nick.c_str(), u->nick.c_str(), filename.c_str());
                                                u->WriteServ("NOTICE %s :%s (%s@%s) attempted to send you a file named %s, which was blocked.", u->nick.c_str(), user->nick.c_str(), user->ident.c_str(), user->dhost.c_str(), filename.c_str());
                                                u->WriteServ("NOTICE %s :If you trust %s and were expecting this, you can type /DCCALLOW HELP for information on the DCCALLOW system.", u->nick.c_str(), user->nick.c_str());
@@ -476,4 +479,3 @@ class ModuleDCCAllow : public Module
 };
 
 MODULE_INIT(ModuleDCCAllow)
-