m_close.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "inspircd.h"
00023
00024
00025
00028 class CommandClose : public Command
00029 {
00030 public:
00031
00032 CommandClose (InspIRCd* Instance) : Command(Instance,"CLOSE", "o", 0)
00033 {
00034 this->source = "m_close.so";
00035 }
00036
00037 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
00038 {
00039 std::map<std::string,int> closed;
00040
00041 for (std::vector<User*>::iterator u = ServerInstance->Users->local_users.begin(); u != ServerInstance->Users->local_users.end(); u++)
00042 {
00043 if ((*u)->registered != REG_ALL)
00044 {
00045 ServerInstance->Users->QuitUser(*u, "Closing all unknown connections per request");
00046 std::string key = ConvToStr((*u)->GetIPString())+"."+ConvToStr((*u)->GetPort());
00047 closed[key]++;
00048 }
00049 }
00050
00051 int total = 0;
00052 for (std::map<std::string,int>::iterator ci = closed.begin(); ci != closed.end(); ci++)
00053 {
00054 user->WriteServ("NOTICE %s :*** Closed %d unknown connection%s from [%s]",user->nick.c_str(),(*ci).second,((*ci).second>1)?"s":"",(*ci).first.c_str());
00055 total += (*ci).second;
00056 }
00057 if (total)
00058 user->WriteServ("NOTICE %s :*** %i unknown connection%s closed",user->nick.c_str(),total,(total>1)?"s":"");
00059 else
00060 user->WriteServ("NOTICE %s :*** No unknown connections found",user->nick.c_str());
00061
00062 return CMD_LOCALONLY;
00063 }
00064 };
00065
00066 class ModuleClose : public Module
00067 {
00068 CommandClose* newcommand;
00069 public:
00070 ModuleClose(InspIRCd* Me)
00071 : Module(Me)
00072 {
00073
00074 newcommand = new CommandClose(ServerInstance);
00075 ServerInstance->AddCommand(newcommand);
00076
00077 }
00078
00079 virtual ~ModuleClose()
00080 {
00081 }
00082
00083 virtual Version GetVersion()
00084 {
00085 return Version("$Id: m_close.cpp 10291 2008-08-25 20:35:51Z w00t $", VF_VENDOR, API_VERSION);
00086 }
00087 };
00088
00089 MODULE_INIT(ModuleClose)