X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spy.cpp;h=12aa0d347d841c21be6bd9ba5da05190816e97c5;hb=4a64082e31c3c3dfa97a1edfb8a3c97fe8d32ea7;hp=7420d6d3c46e5ca3bef25c78c5c8803e0164a931;hpb=d36107cfe9bcc2b6edd64cafa99fdfc77c3a5fd9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spy.cpp b/src/modules/m_spy.cpp index 7420d6d3c..12aa0d347 100644 --- a/src/modules/m_spy.cpp +++ b/src/modules/m_spy.cpp @@ -2,123 +2,49 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2007 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see - * the file COPYING for details. + * the file COPYING for details. * * --------------------------------------------------- */ -/* $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 "inspircd.h" -#include "wildcard.h" -void spy_userlist(User *user, Channel *c) +class ModuleSpy : public Module { - char list[MAXBUF]; - size_t dlen, curlen; - - dlen = curlen = snprintf(list,MAXBUF,"353 %s %c %s :", user->nick, c->IsModeSet('s') ? '@' : c->IsModeSet('p') ? '*' : '=', c->name); - - int numusers = 0; - char* ptr = list + dlen; - - CUList *ulist= c->GetUsers(); - - for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) - { - size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", c->GetPrefixChar(i->first), i->first->nick); - - curlen += ptrlen; - ptr += ptrlen; - - numusers++; - - if (curlen > (480-NICKMAX)) - { - /* list overflowed into multiple numerics */ - user->WriteServ(std::string(list)); - - /* reset our lengths */ - dlen = curlen = snprintf(list,MAXBUF,"353 %s %c %s :", user->nick, c->IsModeSet('s') ? '@' : c->IsModeSet('p') ? '*' : '=', c->name); - ptr = list + dlen; - - ptrlen = 0; - numusers = 0; - } + public: + ModuleSpy() { + ServerInstance->Modules->Attach(I_OnUserList, this); } - /* if whats left in the list isnt empty, send it */ - if (numusers) + virtual ModResult OnUserList(User* user, Channel* Ptr) { - user->WriteServ(std::string(list)); - } - - user->WriteServ("366 %s %s :End of /NAMES list.", user->nick, c->name); - -} + /* User has priv and is NOT on the channel */ + if (user->HasPrivPermission("channels/auspex") && !Ptr->HasUser(user)) + return MOD_RES_ALLOW; -/** Handle /SPYNAMES - */ -class CommandSpynames : public Command -{ - public: - CommandSpynames (InspIRCd* Instance) : Command(Instance,"SPYNAMES", 'o', 0) - { - this->source = "m_spy.so"; - syntax = "{{,}}"; + return MOD_RES_PASSTHRU; } - CmdResult Handle (const char** parameters, int pcnt, User *user) + void Prioritize() { - Channel* c = NULL; - - if (!pcnt) - { - user->WriteServ("366 %s * :End of /NAMES list.",user->nick); - return CMD_FAILURE; - } - - if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0)) - return CMD_FAILURE; - - c = ServerInstance->FindChan(parameters[0]); - if (c) - { - ServerInstance->WriteOpers("*** Oper %s used SPYNAMES to view the users on %s", user->nick, parameters[0]); - spy_userlist(user,c); - } - else - { - user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]); - } - - return CMD_LOCALONLY; + /* 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, PRIORITY_BEFORE, list, 2); } -}; -class ModuleSpy : public Module -{ - CommandSpynames *mycommand2; - public: - ModuleSpy(InspIRCd* Me) : Module(Me) - { - - mycommand2 = new CommandSpynames(ServerInstance); - ServerInstance->AddCommand(mycommand2); - - } - virtual ~ModuleSpy() { } - + virtual Version GetVersion() { - return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION); + return Version("Provides the ability to see the complete names list of channels an oper is not a member of", VF_VENDOR, API_VERSION); } };