]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_check.cpp
kick_channel -> chanrec::KickUser(), server_kick_channel -> chanrec::ServerKickUser()
[user/henk/code/inspircd.git] / src / modules / m_check.cpp
index c905a56e9110d68c67563ee9c527c18170fdbaaa..a00d32b9ef069b3321c89706e14100b529701c8b 100644 (file)
@@ -26,6 +26,9 @@ using namespace std;
 
 /* $ModDesc: Provides the /check command to retrieve information on a user, channel, or IP address */
 
+extern user_hash clientlist;
+extern bool match(const char *, const char *);
+
 static Server *Srv;
 
 class cmd_check : public command_t
@@ -34,9 +37,10 @@ class cmd_check : public command_t
        cmd_check() : command_t("CHECK", 'o', 1)
        {
                this->source = "m_check.so";
+               syntax = "<nickname>|<ip>|<hostmask>|<channel>";
        }
 
-       void Handle (char **parameters, int pcnt, userrec *user)
+       void Handle (const char** parameters, int pcnt, userrec *user)
        {
                userrec *targuser;
                chanrec *targchan;
@@ -67,7 +71,7 @@ class cmd_check : public command_t
                        Srv->SendTo(NULL, user, checkstr + " nuh " + targuser->GetFullHost());
                        Srv->SendTo(NULL, user, checkstr + " realnuh " + targuser->GetFullRealHost());
                        Srv->SendTo(NULL, user, checkstr + " realname " + targuser->fullname);
-                       Srv->SendTo(NULL, user, checkstr + " modes +" + targuser->modes);
+                       Srv->SendTo(NULL, user, checkstr + " modes +" + targuser->FormatModes());
                        Srv->SendTo(NULL, user, checkstr + " server " + targuser->server);
                        if (targuser->awaymsg[0] != 0)
                        {
@@ -82,7 +86,7 @@ class cmd_check : public command_t
                        if (IS_LOCAL(targuser))
                        {
                                /* port information is only held for a local user! */
-                               Srv->SendTo(NULL, user, checkstr + " onport " + ConvToStr(targuser->port));
+                               Srv->SendTo(NULL, user, checkstr + " onport " + ConvToStr(targuser->GetPort()));
                        }
 
                        chliststr = chlist(targuser, targuser);
@@ -128,7 +132,7 @@ class cmd_check : public command_t
                                 * find how many connections from this user's IP -- unlike Asuka,
                                 * I define a clone as coming from the same host. --w00t
                                 */
-                               sprintf(ptr, "%l    ", FindMatchingGlobal(i->second));
+                               sprintf(ptr, "%lu    ", FindMatchingGlobal(i->second));
                                
                                if (flags & UCMODE_OP)
                                {
@@ -154,6 +158,25 @@ class cmd_check : public command_t
                else
                {
                        /*  /check on an IP address, or something that doesn't exist */
+                       long x = 0;
+
+                       /* hostname or other */
+                       for (user_hash::const_iterator a = clientlist.begin(); a != clientlist.end(); a++)
+                       {
+                               if (match(a->second->host, parameters[0]) || match(a->second->dhost, parameters[0]))
+                               {
+                                       /* host or vhost matches mask */
+                                       Srv->SendTo(NULL, user, checkstr + " match " + ConvToStr(++x) + " " + a->second->GetFullRealHost());
+                               }
+                               /* IP address */
+                               else if (match(a->second->GetIPString(), parameters[0]))
+                               {
+                                       /* same IP. */
+                                       Srv->SendTo(NULL, user, checkstr + " match " + ConvToStr(++x) + " " + a->second->GetFullRealHost());
+                               }
+                       }
+
+                       Srv->SendTo(NULL, user, checkstr + " matches " + ConvToStr(x));
                }
 
                Srv->SendTo(NULL, user, checkstr + " END " + std::string(parameters[0]));