1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
20 /* $ModDesc: Provides the /clones command to retrieve information on a user, channel, or IP address */
24 class cmd_clones : public command_t
27 cmd_clones (InspIRCd* Instance) : command_t(Instance,"CLONES", 'o', 1)
29 this->source = "m_clones.so";
33 std::string FindMatchingIP(const irc::string &ipaddr)
35 std::string n = assign(ipaddr);
36 for (user_hash::const_iterator a = ServerInstance->clientlist->begin(); a != ServerInstance->clientlist->end(); a++)
37 if (a->second->GetIPString() == n)
38 return a->second->GetFullRealHost();
42 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
45 std::string clonesstr = "304 " + std::string(user->nick) + " :CLONES";
47 unsigned long limit = atoi(parameters[0]);
50 * Syntax of a /clones reply:
51 * :server.name 304 target :CLONES START
52 * :server.name 304 target :CLONES <count> <ip> <fullhost>
53 * :server.name 304 target :CHECK END
56 user->WriteServ(clonesstr + " START");
58 /* hostname or other */
59 for (clonemap::iterator x = ServerInstance->global_clones.begin(); x != ServerInstance->global_clones.end(); x++)
61 if (x->second >= limit)
62 user->WriteServ(clonesstr + " "+ ConvToStr(x->second) + " " + assign(x->first) + " " + FindMatchingIP(x->first));
65 user->WriteServ(clonesstr + " END");
72 class ModuleClones : public Module
75 cmd_clones *mycommand;
77 ModuleClones(InspIRCd* Me) : Module(Me)
80 mycommand = new cmd_clones(ServerInstance);
81 ServerInstance->AddCommand(mycommand);
84 virtual ~ModuleClones()
88 virtual Version GetVersion()
90 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
93 void Implements(char* List)
95 /* we don't hook anything, nothing required */
102 class ModuleClonesFactory : public ModuleFactory
105 ModuleClonesFactory()
109 ~ModuleClonesFactory()
113 virtual Module * CreateModule(InspIRCd* Me)
115 return new ModuleClones(Me);
120 extern "C" DllExport void * init_module( void )
122 return new ModuleClonesFactory;