1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/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(Module* Creator) : Command(Creator,"CLOSE", 0)
36 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
38 std::map<std::string,int> closed;
40 for (std::vector<User*>::iterator u = ServerInstance->Users->local_users.begin(); u != ServerInstance->Users->local_users.end(); u++)
42 if ((*u)->registered != REG_ALL)
44 ServerInstance->Users->QuitUser(*u, "Closing all unknown connections per request");
45 std::string key = ConvToStr((*u)->GetIPString())+"."+ConvToStr((*u)->GetServerPort());
51 for (std::map<std::string,int>::iterator ci = closed.begin(); ci != closed.end(); ci++)
53 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());
54 total += (*ci).second;
57 user->WriteServ("NOTICE %s :*** %i unknown connection%s closed",user->nick.c_str(),total,(total>1)?"s":"");
59 user->WriteServ("NOTICE %s :*** No unknown connections found",user->nick.c_str());
65 class ModuleClose : public Module
69 ModuleClose(InspIRCd* Me)
70 : Module(Me), cmd(this)
72 ServerInstance->AddCommand(&cmd);
75 virtual ~ModuleClose()
79 virtual Version GetVersion()
81 return Version("$Id$", VF_VENDOR, API_VERSION);
85 MODULE_INIT(ModuleClose)