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 for (LocalUserList::const_iterator u = ServerInstance->Users->local_users.begin(); u != ServerInstance->Users->local_users.end(); ++u)
42 if (user->registered != REG_ALL)
44 ServerInstance->Users->QuitUser(user, "Closing all unknown connections per request");
45 std::string key = ConvToStr(user->GetIPString())+"."+ConvToStr(user->GetServerPort());
51 for (std::map<std::string,int>::iterator ci = closed.begin(); ci != closed.end(); ci++)
53 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());
54 total += (*ci).second;
57 src->WriteServ("NOTICE %s :*** %i unknown connection%s closed",src->nick.c_str(),total,(total>1)?"s":"");
59 src->WriteServ("NOTICE %s :*** No unknown connections found",src->nick.c_str());
65 class ModuleClose : public Module
76 ServerInstance->Modules->AddService(cmd);
79 virtual ~ModuleClose()
83 virtual Version GetVersion()
85 return Version("Provides /CLOSE functionality", VF_VENDOR);
89 MODULE_INIT(ModuleClose)