X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_check.cpp;h=461ac5a2d7889d819e35e4e25fcc02842c3a8973;hb=f5c631ef8641db6455bed23c02e5a39f63f7d6d0;hp=0a0ecab2bdcf12fc01cff4f85482c15cf00e247f;hpb=b43fc66c17c2bef6dca66a966676b8128d5774ee;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 0a0ecab2b..461ac5a2d 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * InspIRCd: (C) 2002-2010 InspIRCd Development Team * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see @@ -41,9 +41,9 @@ class CommandCheck : public Command ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_USER, ext, i->second); if (!value.empty()) - user->SendText(checkstr + " meta:" + item->key + " " + value); - else if (!item->key.empty()) - dumpkeys << " " << item->key; + user->SendText(checkstr + " meta:" + item->name + " " + value); + else if (!item->name.empty()) + dumpkeys << " " << item->name; } if (!dumpkeys.str().empty()) user->SendText(checkstr + " metadata", dumpkeys); @@ -75,6 +75,7 @@ class CommandCheck : public Command if (targuser) { + LocalUser* loctarg = IS_LOCAL(targuser); /* /check on a user */ user->SendText(checkstr + " nuh " + targuser->GetFullHost()); user->SendText(checkstr + " realnuh " + targuser->GetFullRealHost()); @@ -85,7 +86,7 @@ class CommandCheck : public Command user->SendText(checkstr + " uid " + targuser->uuid); user->SendText(checkstr + " signon " + timestring(targuser->signon)); user->SendText(checkstr + " nickts " + timestring(targuser->age)); - if (IS_LOCAL(targuser)) + if (loctarg) user->SendText(checkstr + " lastmsg " + timestring(targuser->idle_lastmsg)); if (IS_AWAY(targuser)) @@ -97,11 +98,42 @@ class CommandCheck : public Command if (IS_OPER(targuser)) { + OperInfo* oper = targuser->oper; /* user is an oper of type ____ */ - user->SendText(checkstr + " opertype " + targuser->oper->NameStr()); + user->SendText(checkstr + " opertype " + oper->NameStr()); + if (loctarg) + { + std::string umodes; + std::string cmodes; + for(char c='A'; c < 'z'; c++) + { + ModeHandler* mh = ServerInstance->Modes->FindMode(c, MODETYPE_USER); + if (mh && mh->NeedsOper() && loctarg->HasModePermission(c, MODETYPE_USER)) + umodes.push_back(c); + mh = ServerInstance->Modes->FindMode(c, MODETYPE_CHANNEL); + if (mh && mh->NeedsOper() && loctarg->HasModePermission(c, MODETYPE_CHANNEL)) + cmodes.push_back(c); + } + user->SendText(checkstr + " modeperms user=" + umodes + " channel=" + cmodes); + std::string opcmds; + for(std::set::iterator i = oper->AllowedOperCommands.begin(); i != oper->AllowedOperCommands.end(); i++) + { + opcmds.push_back(' '); + opcmds.append(*i); + } + std::stringstream opcmddump(opcmds); + user->SendText(checkstr + " commandperms", opcmddump); + std::string privs; + for(std::set::iterator i = oper->AllowedPrivs.begin(); i != oper->AllowedPrivs.end(); i++) + { + privs.push_back(' '); + privs.append(*i); + } + std::stringstream privdump(privs); + user->SendText(checkstr + " permissions", privdump); + } } - LocalUser* loctarg = IS_LOCAL(targuser); if (loctarg) { user->SendText(checkstr + " clientaddr " + irc::sockets::satouser(loctarg->client_sa)); @@ -157,6 +189,20 @@ class CommandCheck : public Command user->SendText(checkstr + " member " + tmpbuf); } + irc::modestacker modestack(true); + std::string letter_b("b"); + for(BanList::iterator b = targchan->bans.begin(); b != targchan->bans.end(); ++b) + { + modestack.Push('b', b->data); + } + std::vector stackresult; + std::vector dummy; + while (modestack.GetStackedLine(stackresult)) + { + creator->ProtoSendMode(user, TYPE_CHANNEL, targchan, stackresult, dummy); + stackresult.clear(); + } + FOREACH_MOD(I_OnSyncChannel,OnSyncChannel(targchan,creator,user)); dumpExt(user, checkstr, targchan); } else @@ -204,13 +250,33 @@ class ModuleCheck : public Module public: ModuleCheck() : mycommand(this) { - ServerInstance->AddCommand(&mycommand); + } + + void init() + { + ServerInstance->Modules->AddService(mycommand); } ~ModuleCheck() { } + void ProtoSendMode(void* uv, TargetTypeFlags, void*, const std::vector& result, const std::vector&) + { + User* user = (User*)uv; + std::string checkstr(":"); + checkstr.append(ServerInstance->Config->ServerName); + checkstr.append(" 304 "); + checkstr.append(user->nick); + checkstr.append(" :CHECK modelist"); + for(unsigned int i=0; i < result.size(); i++) + { + checkstr.append(" "); + checkstr.append(result[i]); + } + user->SendText(checkstr); + } + Version GetVersion() { return Version("CHECK command, view user/channel details", VF_VENDOR|VF_OPTCOMMON);