1 /* +------------------------------------+
3 * +------------------------------------+
5 * UnrealIRCd 4.0 (C) 2007 Carsten Valdemar Munk
6 * This program is free but copyrighted software; see
7 * the file COPYING for details.
9 * ---------------------------------------------------
17 /* $ModDesc: Provides /CLOSE functionality */
21 class cmd_close : public command_t
24 /* Command 'close', needs operator */
25 cmd_close (InspIRCd* Instance) : command_t(Instance,"CLOSE", 'o', 0)
27 this->source = "m_close.so";
30 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
32 std::map<std::string,int> closed;
34 for (std::vector<userrec*>::iterator u = ServerInstance->local_users.begin(); u != ServerInstance->local_users.end(); u++)
36 if ((*u)->registered != REG_ALL)
38 userrec::QuitUser(ServerInstance, *u, "Closing all unknown connections per request");
39 std::string key = ConvToStr((*u)->GetIPString())+"."+ConvToStr((*u)->GetPort());
45 for (std::map<std::string,int>::iterator ci = closed.begin(); ci != closed.end(); ci++)
47 user->WriteServ("NOTICE %s :*** Closed %d unknown connection%s from [%s]",user->nick,(*ci).second,((*ci).second>1)?"s":"",(*ci).first.c_str());
48 total += (*ci).second;
51 user->WriteServ("NOTICE %s :*** %i unknown connection%s closed",user->nick,total,(total>1)?"s":"");
53 user->WriteServ("NOTICE %s :*** No unknown connections found",user->nick);
59 class ModuleClose : public Module
61 cmd_close* newcommand;
63 ModuleClose(InspIRCd* Me)
66 // Create a new command
67 newcommand = new cmd_close(ServerInstance);
68 ServerInstance->AddCommand(newcommand);
71 virtual ~ModuleClose()
75 virtual Version GetVersion()
77 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
81 MODULE_INIT(ModuleClose)