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->WriteNotice("*** Closed " + ConvToStr(ci->second) + " unknown " + (ci->second == 1 ? "connection" : "connections") +
54 " from [" + ci->first + "]");
58 src->WriteNotice("*** " + ConvToStr(total) + " unknown " + (total == 1 ? "connection" : "connections") + " closed");
60 src->WriteNotice("*** No unknown connections found");
66 class ModuleClose : public Module
75 void init() CXX11_OVERRIDE
77 ServerInstance->Modules->AddService(cmd);
80 Version GetVersion() CXX11_OVERRIDE
82 return Version("Provides /CLOSE functionality", VF_VENDOR);
86 MODULE_INIT(ModuleClose)