1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 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 *src)
38 std::map<std::string,int> closed;
40 std::vector<LocalUser*>::reverse_iterator u = ServerInstance->Users->local_users.rbegin();
41 while (u != ServerInstance->Users->local_users.rend())
43 LocalUser* user = *u++;
44 if (user->registered != REG_ALL)
46 ServerInstance->Users->QuitUser(user, "Closing all unknown connections per request");
47 std::string key = ConvToStr(user->GetIPString())+"."+ConvToStr(user->GetServerPort());
53 for (std::map<std::string,int>::iterator ci = closed.begin(); ci != closed.end(); ci++)
55 src->WriteServ("NOTICE %s :*** Closed %d unknown connection%s from [%s]",src->nick.c_str(),(*ci).second,((*ci).second>1)?"s":"",(*ci).first.c_str());
56 total += (*ci).second;
59 src->WriteServ("NOTICE %s :*** %i unknown connection%s closed",src->nick.c_str(),total,(total>1)?"s":"");
61 src->WriteServ("NOTICE %s :*** No unknown connections found",src->nick.c_str());
67 class ModuleClose : public Module
74 ServerInstance->AddCommand(&cmd);
77 virtual ~ModuleClose()
81 virtual Version GetVersion()
83 return Version("Provides /CLOSE functionality", VF_VENDOR);
87 MODULE_INIT(ModuleClose)