-/* +------------------------------------+\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
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd: (C) 2002-2010 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
+ *
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include "inspircd.h"
+
+/* $ModDesc: Provides the /clones command to retrieve information on clones. */
+
+/** Handle /CHECK
+ */
+class CommandClones : public Command
+{
+ public:
+ CommandClones(Module* Creator) : Command(Creator,"CLONES", 1)
+ {
+ flags_needed = 'o'; syntax = "<limit>";
+ }
+
+ CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
+ {
+
+ std::string clonesstr = "304 " + std::string(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 :CHECK 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)
+ {
+ ServerInstance->AddCommand(&cmd);
+ }
+
+ virtual ~ModuleClones()
+ {
+ }
+
+ virtual Version GetVersion()
+ {
+ return Version("Provides the /clones command to retrieve information on clones.", VF_VENDOR);
+ }
+
+
+};
+
+MODULE_INIT(ModuleClones)