/* $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
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;
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)
{
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);
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]));