class CheckContext
{
+ private:
User* const user;
const std::string& target;
+ std::string FormatTime(time_t ts)
+ {
+ std::string timestr(InspIRCd::TimeString(ts, "%Y-%m-%d %H:%M:%S UTC (", true));
+ timestr.append(ConvToStr(ts));
+ timestr.push_back(')');
+ return timestr;
+ }
+
public:
CheckContext(User* u, const std::string& targetstr)
: user(u)
user->WriteRemoteNumeric(RPL_CHECK, type, text);
}
+ void Write(const std::string& type, time_t ts)
+ {
+ user->WriteRemoteNumeric(RPL_CHECK, type, FormatTime(ts));
+ }
+
User* GetUser() const { return user; }
void DumpListMode(const ListModeBase::ModeList* list)
flags_needed = 'o'; syntax = "<nickname>|<ip>|<hostmask>|<channel> <server>";
}
- std::string timestring(time_t time)
+ CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
{
- char timebuf[60];
- struct tm *mytime = gmtime(&time);
- strftime(timebuf, 59, "%Y-%m-%d %H:%M:%S UTC (", mytime);
- std::string ret(timebuf);
- ret.append(ConvToStr(time)).push_back(')');
- return ret;
- }
-
- CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
- {
- if (parameters.size() > 1 && parameters[1] != ServerInstance->Config->ServerName)
+ if (parameters.size() > 1 && !irc::equals(parameters[1], ServerInstance->Config->ServerName))
return CMD_SUCCESS;
User *targuser;
/* /check on a user */
context.Write("nuh", targuser->GetFullHost());
context.Write("realnuh", targuser->GetFullRealHost());
- context.Write("realname", targuser->fullname);
- context.Write("modes", std::string("+") + targuser->FormatModes());
+ context.Write("realname", targuser->GetRealName());
+ context.Write("modes", targuser->GetModeLetters());
context.Write("snomasks", GetSnomasks(targuser));
context.Write("server", targuser->server->GetName());
context.Write("uid", targuser->uuid);
- context.Write("signon", timestring(targuser->signon));
- context.Write("nickts", timestring(targuser->age));
+ context.Write("signon", targuser->signon);
+ context.Write("nickts", targuser->age);
if (loctarg)
- context.Write("lastmsg", timestring(loctarg->idle_lastmsg));
+ context.Write("lastmsg", loctarg->idle_lastmsg);
if (targuser->IsAway())
{
/* user is away */
- context.Write("awaytime", timestring(targuser->awaytime));
+ context.Write("awaytime", targuser->awaytime);
context.Write("awaymsg", targuser->awaymsg);
}
std::string umodes = GetAllowedOperOnlyModes(loctarg, MODETYPE_USER);
std::string cmodes = GetAllowedOperOnlyModes(loctarg, MODETYPE_CHANNEL);
context.Write("modeperms", "user=" + umodes + " channel=" + cmodes);
-
- CheckContext::List opcmdlist(context, "commandperms");
- for (OperInfo::PrivSet::const_iterator i = oper->AllowedOperCommands.begin(); i != oper->AllowedOperCommands.end(); ++i)
- opcmdlist.Add(*i);
- opcmdlist.Flush();
- CheckContext::List privlist(context, "permissions");
- for (OperInfo::PrivSet::const_iterator i = oper->AllowedPrivs.begin(); i != oper->AllowedPrivs.end(); ++i)
- privlist.Add(*i);
- privlist.Flush();
+ context.Write("commandperms", oper->AllowedOperCommands.ToString());
+ context.Write("permissions", oper->AllowedPrivs.ToString());
}
}
else if (targchan)
{
/* /check on a channel */
- context.Write("timestamp", timestring(targchan->age));
+ context.Write("timestamp", targchan->age);
if (!targchan->topic.empty())
{
/* there is a topic, assume topic related information exists */
context.Write("topic", targchan->topic);
context.Write("topic_setby", targchan->setby);
- context.Write("topic_setat", timestring(targchan->topicset));
+ context.Write("topic_setat", targchan->topicset);
}
context.Write("modes", targchan->ChanModes(true));
const UserManager::CloneCounts& clonecount = ServerInstance->Users->GetCloneCounts(i->first);
context.Write("member", InspIRCd::Format("%-3u %s%s (%s@%s) %s ", clonecount.global,
i->second->GetAllPrefixChars().c_str(), i->first->nick.c_str(),
- i->first->ident.c_str(), i->first->dhost.c_str(), i->first->fullname.c_str()));
+ i->first->ident.c_str(), i->first->GetDisplayedHost().c_str(), i->first->GetRealName().c_str()));
}
const ModeParser::ListModeList& listmodes = ServerInstance->Modes->GetListModes();
const user_hash& users = ServerInstance->Users->GetUsers();
for (user_hash::const_iterator a = users.begin(); a != users.end(); ++a)
{
- if (InspIRCd::Match(a->second->host, parameters[0], ascii_case_insensitive_map) || InspIRCd::Match(a->second->dhost, parameters[0], ascii_case_insensitive_map))
+ if (InspIRCd::Match(a->second->GetRealHost(), parameters[0], ascii_case_insensitive_map) || InspIRCd::Match(a->second->GetDisplayedHost(), parameters[0], ascii_case_insensitive_map))
{
/* host or vhost matches mask */
- context.Write("match", ConvToStr(++x) + " " + a->second->GetFullRealHost() + " " + a->second->GetIPString() + " " + a->second->fullname);
+ context.Write("match", ConvToStr(++x) + " " + a->second->GetFullRealHost() + " " + a->second->GetIPString() + " " + a->second->GetRealName());
}
/* IP address */
else if (InspIRCd::MatchCIDR(a->second->GetIPString(), parameters[0]))
{
/* same IP. */
- context.Write("match", ConvToStr(++x) + " " + a->second->GetFullRealHost() + " " + a->second->GetIPString() + " " + a->second->fullname);
+ context.Write("match", ConvToStr(++x) + " " + a->second->GetFullRealHost() + " " + a->second->GetIPString() + " " + a->second->GetRealName());
}
}
return CMD_SUCCESS;
}
- RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
+ RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
{
if ((parameters.size() > 1) && (parameters[1].find('.') != std::string::npos))
return ROUTE_OPT_UCAST(parameters[1]);