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/>.
25 class CommandClose : public Command
28 /* Command 'close', needs operator */
29 CommandClose(Module* Creator) : Command(Creator,"CLOSE", 0)
34 CmdResult Handle (const std::vector<std::string> ¶meters, User *src)
36 std::map<std::string,int> closed;
38 const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
39 for (UserManager::LocalList::const_iterator u = list.begin(); u != list.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 Version GetVersion() CXX11_OVERRIDE
77 return Version("Provides /CLOSE functionality", VF_VENDOR);
81 MODULE_INIT(ModuleClose)