1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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 * ---------------------------------------------------
13 * Based on the UnrealIRCd 4.0 (1.1.x fork) module
15 * UnrealIRCd 4.0 (C) 2007 Carsten Valdemar Munk
16 * This program is free but copyrighted software; see
17 * the file COPYING for details.
19 * ---------------------------------------------------
24 /* $ModDesc: Provides /CLOSE functionality */
28 class CommandClose : public Command
31 /* Command 'close', needs operator */
32 CommandClose (InspIRCd* Instance) : Command(Instance,"CLOSE", "o", 0)
34 this->source = "m_close.so";
37 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
39 std::map<std::string,int> closed;
41 for (std::vector<User*>::iterator u = ServerInstance->Users->local_users.begin(); u != ServerInstance->Users->local_users.end(); u++)
43 if ((*u)->registered != REG_ALL)
45 ServerInstance->Users->QuitUser(*u, "Closing all unknown connections per request");
46 std::string key = ConvToStr((*u)->GetIPString())+"."+ConvToStr((*u)->GetPort());
52 for (std::map<std::string,int>::iterator ci = closed.begin(); ci != closed.end(); ci++)
54 user->WriteServ("NOTICE %s :*** Closed %d unknown connection%s from [%s]",user->nick.c_str(),(*ci).second,((*ci).second>1)?"s":"",(*ci).first.c_str());
55 total += (*ci).second;
58 user->WriteServ("NOTICE %s :*** %i unknown connection%s closed",user->nick.c_str(),total,(total>1)?"s":"");
60 user->WriteServ("NOTICE %s :*** No unknown connections found",user->nick.c_str());
66 class ModuleClose : public Module
68 CommandClose* newcommand;
70 ModuleClose(InspIRCd* Me)
73 // Create a new command
74 newcommand = new CommandClose(ServerInstance);
75 ServerInstance->AddCommand(newcommand);
79 virtual ~ModuleClose()
83 virtual Version GetVersion()
85 return Version("$Id$", VF_VENDOR, API_VERSION);
89 MODULE_INIT(ModuleClose)