1 /* +------------------------------------+
3 * +------------------------------------+
5 * UnrealIRCd 4.0 (C) 2008 Carsten Valdemar Munk
6 * This program is free but copyrighted software; see
7 * the file COPYING for details.
9 * ---------------------------------------------------
14 /* $ModDesc: Provides /CLOSE functionality */
18 class CommandClose : public Command
21 /* Command 'close', needs operator */
22 CommandClose (InspIRCd* Instance) : Command(Instance,"CLOSE", "o", 0)
24 this->source = "m_close.so";
27 CmdResult Handle (const char* const* parameters, int pcnt, User *user)
29 std::map<std::string,int> closed;
31 for (std::vector<User*>::iterator u = ServerInstance->Users->local_users.begin(); u != ServerInstance->Users->local_users.end(); u++)
33 if ((*u)->registered != REG_ALL)
35 User::QuitUser(ServerInstance, *u, "Closing all unknown connections per request");
36 std::string key = ConvToStr((*u)->GetIPString())+"."+ConvToStr((*u)->GetPort());
42 for (std::map<std::string,int>::iterator ci = closed.begin(); ci != closed.end(); ci++)
44 user->WriteServ("NOTICE %s :*** Closed %d unknown connection%s from [%s]",user->nick,(*ci).second,((*ci).second>1)?"s":"",(*ci).first.c_str());
45 total += (*ci).second;
48 user->WriteServ("NOTICE %s :*** %i unknown connection%s closed",user->nick,total,(total>1)?"s":"");
50 user->WriteServ("NOTICE %s :*** No unknown connections found",user->nick);
56 class ModuleClose : public Module
58 CommandClose* newcommand;
60 ModuleClose(InspIRCd* Me)
63 // Create a new command
64 newcommand = new CommandClose(ServerInstance);
65 ServerInstance->AddCommand(newcommand);
69 virtual ~ModuleClose()
73 virtual Version GetVersion()
75 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
79 MODULE_INIT(ModuleClose)