]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_clones.cpp
m_delayjoin Only send JOIN on mode change if the mode being changed is a prefix mode
[user/henk/code/inspircd.git] / src / modules / m_clones.cpp
index 429b9c2b900b693c0b877f8712201007ce3abea5..92b1bda78fb8a8d4d186a072405c1a56340294ed 100644 (file)
@@ -1 +1,93 @@
-/*       +------------------------------------+\r *       | Inspire Internet Relay Chat Daemon |\r *       +------------------------------------+\r *\r *  InspIRCd: (C) 2002-2007 InspIRCd Development Team\r * See: http://www.inspircd.org/wiki/index.php/Credits\r *\r * This program is free but copyrighted software; see\r *            the file COPYING for details.\r *\r * ---------------------------------------------------\r */\r\r#include "inspircd.h"\r#include "users.h"\r#include "channels.h"\r#include "modules.h"\r#include "wildcard.h"\r\r/* $ModDesc: Provides the /clones command to retrieve information on a user, channel, or IP address */\r\r/** Handle /CHECK\r */\rclass cmd_clones : public command_t\r{\r public:\r   cmd_clones (InspIRCd* Instance) : command_t(Instance,"CLONES", 'o', 1)\r {\r              this->source = "m_clones.so";\r          syntax = "<limit>";\r    }\r\r     std::string FindMatchingIP(const irc::string &ipaddr)\r  {\r              std::string n = assign(ipaddr);\r                for (user_hash::const_iterator a = ServerInstance->clientlist->begin(); a != ServerInstance->clientlist->end(); a++)\r                   if (a->second->GetIPString() == n)\r                             return a->second->GetFullRealHost();\r           return "<?>";\r  }\r\r     CmdResult Handle (const char** parameters, int pcnt, userrec *user)\r    {\r\r             std::string clonesstr = "304 " + std::string(user->nick) + " :CLONES";\r\r                unsigned long limit = atoi(parameters[0]);\r\r            /*\r              * Syntax of a /clones reply:\r           *  :server.name 304 target :CLONES START\r               *  :server.name 304 target :CLONES <count> <ip> <fullhost>\r             *  :server.name 304 target :CHECK END\r          */\r\r           user->WriteServ(clonesstr + " START");\r\r                /* hostname or other */\r                for (clonemap::iterator x = ServerInstance->global_clones.begin(); x != ServerInstance->global_clones.end(); x++)\r              {\r                      if (x->second >= limit)\r                                user->WriteServ(clonesstr + " "+ ConvToStr(x->second) + " " + assign(x->first) + " " + FindMatchingIP(x->first));\r              }\r\r             user->WriteServ(clonesstr + " END");\r\r          return CMD_LOCALONLY;\r  }\r};\r\r\rclass ModuleClones : public Module\r{\r private:\r  cmd_clones *mycommand;\r public:\r        ModuleClones(InspIRCd* Me) : Module(Me)\r        {\r              \r               mycommand = new cmd_clones(ServerInstance);\r            ServerInstance->AddCommand(mycommand);\r }\r      \r       virtual ~ModuleClones()\r        {\r      }\r      \r       virtual Version GetVersion()\r   {\r              return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);\r    }\r\r     void Implements(char* List)\r    {\r              /* we don't hook anything, nothing required */\r }\r      \r};\r\rMODULE_INIT(ModuleClones)\r
\ No newline at end of file
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2007 Craig Edwards <craigedwards@brainbox.cc>
+ *
+ * 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.
+ *
+ * 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/>.
+ */
+
+
+#include "inspircd.h"
+
+/* $ModDesc: Provides the /CLONES command to retrieve information on clones. */
+
+/** Handle /CLONES
+ */
+class CommandClones : public Command
+{
+ public:
+       CommandClones(Module* Creator) : Command(Creator,"CLONES", 1)
+       {
+               flags_needed = 'o'; syntax = "<limit>";
+       }
+
+       CmdResult Handle (const std::vector<std::string> &parameters, User *user)
+       {
+
+               std::string clonesstr = "304 " + user->nick + " :CLONES";
+
+               unsigned long limit = atoi(parameters[0].c_str());
+
+               /*
+                * Syntax of a /clones reply:
+                *  :server.name 304 target :CLONES START
+                *  :server.name 304 target :CLONES <count> <ip>
+                *  :server.name 304 target :CLONES END
+                */
+
+               user->WriteServ(clonesstr + " START");
+
+               /* hostname or other */
+               // XXX I really don't like marking global_clones public for this. at all. -- w00t
+               for (clonemap::iterator x = ServerInstance->Users->global_clones.begin(); x != ServerInstance->Users->global_clones.end(); x++)
+               {
+                       if (x->second >= limit)
+                               user->WriteServ(clonesstr + " "+ ConvToStr(x->second) + " " + x->first.str());
+               }
+
+               user->WriteServ(clonesstr + " END");
+
+               return CMD_SUCCESS;
+       }
+};
+
+
+class ModuleClones : public Module
+{
+ private:
+       CommandClones cmd;
+ public:
+       ModuleClones() : cmd(this)
+       {
+       }
+
+       void init()
+       {
+               ServerInstance->Modules->AddService(cmd);
+       }
+
+       virtual ~ModuleClones()
+       {
+       }
+
+       virtual Version GetVersion()
+       {
+               return Version("Provides the /CLONES command to retrieve information on clones.", VF_VENDOR);
+       }
+
+
+};
+
+MODULE_INIT(ModuleClones)