2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5 * Copyright (C) 2007 Carsten Valdemar Munk <carsten.munk+inspircd@gmail.com>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 /* $ModDesc: Provides /CLOSE functionality */
27 class CommandClose : public Command
30 /* Command 'close', needs operator */
31 CommandClose(Module* Creator) : Command(Creator,"CLOSE", 0)
35 CmdResult Handle (const std::vector<std::string> ¶meters, User *src)
37 std::map<std::string,int> closed;
39 std::vector<LocalUser*>::reverse_iterator u = ServerInstance->Users->local_users.rbegin();
40 while (u != ServerInstance->Users->local_users.rend())
42 LocalUser* user = *u++;
43 if (user->registered != REG_ALL)
45 ServerInstance->Users->QuitUser(user, "Closing all unknown connections per request");
46 std::string key = ConvToStr(user->GetIPString())+"."+ConvToStr(user->GetServerPort());
52 for (std::map<std::string,int>::iterator ci = closed.begin(); ci != closed.end(); ci++)
54 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());
55 total += (*ci).second;
58 src->WriteServ("NOTICE %s :*** %i unknown connection%s closed",src->nick.c_str(),total,(total>1)?"s":"");
60 src->WriteServ("NOTICE %s :*** No unknown connections found",src->nick.c_str());
66 class ModuleClose : public Module
73 ServerInstance->AddCommand(&cmd);
76 virtual ~ModuleClose()
80 virtual Version GetVersion()
82 return Version("Provides /CLOSE functionality", VF_VENDOR);
86 MODULE_INIT(ModuleClose)