X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spy.cpp;h=053381472540cc8d77d691569b412836c515fee7;hb=83137d5f9274832f152acc7d19de3cb0897f9630;hp=96cffd91aa9db83ea077a7ccf4eb4947783dc0e0;hpb=66098d307c036997e51eaea21724615e27fdc3e9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spy.cpp b/src/modules/m_spy.cpp index 96cffd91a..053381472 100644 --- a/src/modules/m_spy.cpp +++ b/src/modules/m_spy.cpp @@ -2,156 +2,42 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. - * E-mail: - * - * - * - * Written by Craig Edwards, Craig McLure, and others. + * InspIRCd: (C) 2002-2008 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits + * * This program is free but copyrighted software; see - * the file COPYING for details. + * the file COPYING for details. * * --------------------------------------------------- */ -/* NO, THIS MODULE DOES NOT SPY ON CHANNELS OR USERS. - * IT JUST ALLOWS OPERS TO SEE +s CHANNELS IN LIST AND - * WHOIS, WHICH IS SUPPORTED BY MOST IRCDS IN CORE. - */ - -using namespace std; - -/* $ModDesc: Provides SPYLIST and SPYNAMES capability, allowing opers to see who's in +s channels */ +/* $ModDesc: Provides the ability to see the complete names list of channels an oper is not a member of */ -#include -#include -#include -#include "globals.h" -#include "inspircd_config.h" -#include -#include "users.h" -#include "channels.h" -#include "modules.h" -#include "commands.h" -#include "socket.h" -#include "helperfuncs.h" #include "inspircd.h" -#include "inspstring.h" -#include "hashcomp.h" -#include "xline.h" -#include "typedefs.h" -#include "cull_list.h" -#include "aes.h" - -#define nspace __gnu_cxx - - - -extern InspIRCd* ServerInstance; -extern chan_hash chanlist; - -void spy_userlist(userrec *user,chanrec *c) -{ - static char list[MAXBUF]; - - if ((!c) || (!user)) - return; - - snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name); - - CUList *ulist= c->GetUsers(); - for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) - { - strlcat(list,c->GetStatusChar(i->second),MAXBUF); - strlcat(list,i->second->nick,MAXBUF); - strlcat(list," ",MAXBUF); - if (strlen(list)>(480-NICKMAX)) - { - /* list overflowed into - * multiple numerics */ - user->WriteServ(std::string(list)); - snprintf(list,MAXBUF,"353 %s = %s :", user->nick, c->name); - } - } - /* if whats left in the list isnt empty, send it */ - if (list[strlen(list)-1] != ':') - { - user->WriteServ(std::string(list)); - } -} - - - -class cmd_spylist : public command_t -{ - public: - cmd_spylist (InspIRCd* Instance) : command_t(Instance,"SPYLIST", 'o', 0) - { - this->source = "m_spy.so"; - syntax = ""; - } - - void Handle (const char** parameters, int pcnt, userrec *user) - { - ServerInstance->WriteOpers("*** Oper %s used SPYLIST to list +s/+p channels and keys.",user->nick); - user->WriteServ("321 %s Channel :Users Name",user->nick); - for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++) - { - user->WriteServ("322 %s %s %d :[+%s] %s",user->nick,i->second->name,i->second->GetUserCounter(),i->second->ChanModes(true),i->second->topic); - } - user->WriteServ("323 %s :End of channel list.",user->nick); - } -}; +#include "wildcard.h" -class cmd_spynames : public command_t +class ModuleSpy : public Module { - public: - cmd_spynames (InspIRCd* Instance) : command_t(Instance,"SPYNAMES", 'o', 0) + public: + ModuleSpy(InspIRCd* Me) : Module(Me) { - this->source = "m_spy.so"; - syntax = "{{,}}"; + ServerInstance->Modules->Attach(I_OnUserList, this); } - void Handle (const char** parameters, int pcnt, userrec *user) + virtual int OnUserList(User* user, Channel* Ptr, CUList* &nameslist) { - chanrec* c; - - if (!pcnt) - { - user->WriteServ("366 %s * :End of /NAMES list.",user->nick); - return; - } + /* User is an oper and is NOT on the channel */ + if (IS_OPER(user) && !Ptr->HasUser(user)) + return -1; - if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 1)) - return; - - ServerInstance->WriteOpers("*** Oper %s used SPYNAMES to view the users on %s",user->nick,parameters[0]); - - c = ServerInstance->FindChan(parameters[0]); - if (c) - { - spy_userlist(user,c); - user->WriteServ("366 %s %s :End of /NAMES list.", user->nick, c->name); - } - else - { - user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); - } + return 0; } -}; -class ModuleSpy : public Module -{ - cmd_spylist *mycommand; - cmd_spynames *mycommand2; - public: - ModuleSpy(InspIRCd* Me) : Module::Module(Me) - { - - mycommand = new cmd_spylist(ServerInstance); - mycommand2 = new cmd_spynames(ServerInstance); - ServerInstance->AddCommand(mycommand); - ServerInstance->AddCommand(mycommand2); + void Prioritize() + { + /* To ensure that we get priority over namesx and delayjoin for names list generation */ + Module* list[] = { ServerInstance->Modules->Find("m_namesx.so"), ServerInstance->Modules->Find("m_delayjoin.so") }; + ServerInstance->Modules->SetPriority(this, I_OnUserList, PRIO_BEFORE, list, 2); } virtual ~ModuleSpy() @@ -160,31 +46,9 @@ class ModuleSpy : public Module virtual Version GetVersion() { - return Version(1, 0, 0, 0, VF_VENDOR); - } -}; - - -class ModuleSpyFactory : public ModuleFactory -{ - public: - ModuleSpyFactory() - { + return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION); } - - ~ModuleSpyFactory() - { - } - - virtual Module * CreateModule(InspIRCd* Me) - { - return new ModuleSpy(Me); - } - }; +MODULE_INIT(ModuleSpy) -extern "C" void * init_module( void ) -{ - return new ModuleSpyFactory; -}