diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-06-17 11:24:50 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-06-17 11:24:50 +0000 |
commit | 558ceaf16b422c1cd47aec99a80889ec7f6c4a12 (patch) | |
tree | 2be5922765025234eedcfe2e2003e95ff1636b97 | |
parent | 38c970bc5388fa1357b493f2dd0bfaaa9e8ac539 (diff) |
Finished m_check. I am the best. It only took me 3 months :)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4023 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/modules/m_check.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 68c677d09..3ab31ebbc 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -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 @@ -154,6 +157,35 @@ class cmd_check : public command_t else { /* /check on an IP address, or something that doesn't exist */ + struct sockaddr_in addr; + long x = 0; + + if (inet_aton(parameters[0], &addr.sin_addr) == 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()); + } + } + } + else + { + /* IP address */ + for (user_hash::const_iterator a = clientlist.begin(); a != clientlist.end(); a++) + { + if (addr.sin_addr.s_addr == a->second->ip4.s_addr) + { + /* 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])); |