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 * ---------------------------------------------------
17 /* $ModDesc: Provides the /clones command to retrieve information on a user, channel, or IP address */
21 class CommandClones : public Command
24 CommandClones (InspIRCd* Instance) : Command(Instance,"CLONES", 'o', 1)
26 this->source = "m_clones.so";
30 std::string FindMatchingIP(const irc::string &ipaddr)
32 std::string n = assign(ipaddr);
33 for (user_hash::const_iterator a = ServerInstance->clientlist->begin(); a != ServerInstance->clientlist->end(); a++)
34 if (a->second->GetIPString() == n)
35 return a->second->GetFullRealHost();
39 CmdResult Handle (const char** parameters, int pcnt, User *user)
42 std::string clonesstr = "304 " + std::string(user->nick) + " :CLONES";
44 unsigned long limit = atoi(parameters[0]);
47 * Syntax of a /clones reply:
48 * :server.name 304 target :CLONES START
49 * :server.name 304 target :CLONES <count> <ip> <fullhost>
50 * :server.name 304 target :CHECK END
53 user->WriteServ(clonesstr + " START");
55 /* hostname or other */
56 for (clonemap::iterator x = ServerInstance->global_clones.begin(); x != ServerInstance->global_clones.end(); x++)
58 if (x->second >= limit)
59 user->WriteServ(clonesstr + " "+ ConvToStr(x->second) + " " + assign(x->first) + " " + FindMatchingIP(x->first));
62 user->WriteServ(clonesstr + " END");
69 class ModuleClones : public Module
72 CommandClones *mycommand;
74 ModuleClones(InspIRCd* Me) : Module(Me)
77 mycommand = new CommandClones(ServerInstance);
78 ServerInstance->AddCommand(mycommand);
82 virtual ~ModuleClones()
86 virtual Version GetVersion()
88 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
91 void Implements(char* List)
93 /* we don't hook anything, nothing required */
98 MODULE_INIT(ModuleClones)