]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_check.cpp
Merge pull request #92 from Robby-/insp20-headers
[user/henk/code/inspircd.git] / src / modules / m_check.cpp
index 231064431c8a6752398318acb1b317f10ae83c1a..cabfd02bcfe782f2128f4ceb57b93427820e95b0 100644 (file)
@@ -1,16 +1,25 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
  *
- *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
+ *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2006-2007 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
  *
- * This program is free but copyrighted software; see
- *            the file COPYING for details.
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
  *
- * ---------------------------------------------------
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+
 #include "inspircd.h"
 
 /* $ModDesc: Provides the /check command to retrieve information on a user, channel, or IP address */
@@ -75,6 +84,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 +95,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 +107,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<std::string>::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<std::string>::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));
@@ -218,7 +259,11 @@ class ModuleCheck : public Module
  public:
        ModuleCheck() : mycommand(this)
        {
-               ServerInstance->AddCommand(&mycommand);
+       }
+
+       void init()
+       {
+               ServerInstance->Modules->AddService(mycommand);
        }
 
        ~ModuleCheck()