From 4818b1bc1b0dd8560b0c83901aa33ecaf6fb1275 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 28 Jan 2019 16:45:14 +0000 Subject: Fix not checking for server names case insensitively. --- src/modules/m_check.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/m_check.cpp') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 1d030acc6..2d06df199 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -142,7 +142,7 @@ class CommandCheck : public Command CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE { - 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; -- cgit v1.3.1-10-gc9f91 From f434c03f518d8aa9e7ee088e28125a947e6c95a5 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 4 Feb 2019 13:10:23 +0000 Subject: m_check: replace timestring() with a Write() overlod. --- src/modules/m_check.cpp | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'src/modules/m_check.cpp') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 2d06df199..ecfe4dcb4 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -30,9 +30,18 @@ enum 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) @@ -51,6 +60,11 @@ class CheckContext 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) @@ -130,16 +144,6 @@ class CommandCheck : public Command flags_needed = 'o'; syntax = "||| "; } - std::string timestring(time_t time) - { - 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(User* user, const Params& parameters) CXX11_OVERRIDE { if (parameters.size() > 1 && !irc::equals(parameters[1], ServerInstance->Config->ServerName)) @@ -173,15 +177,15 @@ class CommandCheck : public Command 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); } @@ -237,14 +241,14 @@ class CommandCheck : public Command 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)); -- cgit v1.3.1-10-gc9f91 From 7141ccc5bbf043ae2891905f8059635981b36717 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 4 Feb 2019 14:18:32 +0000 Subject: m_check: remove unnecessary usage of CheckContext::List. --- src/modules/m_check.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/modules/m_check.cpp') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index ecfe4dcb4..5e1c01acb 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -199,13 +199,8 @@ class CommandCheck : public Command 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"); - opcmdlist.Add(oper->AllowedOperCommands.ToString()); - opcmdlist.Flush(); - CheckContext::List privlist(context, "permissions"); - privlist.Add(oper->AllowedPrivs.ToString()); - privlist.Flush(); + context.Write("commandperms", oper->AllowedOperCommands.ToString()); + context.Write("permissions", oper->AllowedPrivs.ToString()); } } -- cgit v1.3.1-10-gc9f91 From 4690bbdee8b5a91938e3e2ac86f606951cccf2e8 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 4 Feb 2019 14:22:49 +0000 Subject: m_check: split modeperms into chanmodeperms and usermodeperms. --- src/modules/m_check.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/modules/m_check.cpp') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 5e1c01acb..39f0d190a 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -196,9 +196,8 @@ class CommandCheck : public Command context.Write("opertype", oper->name); if (loctarg) { - std::string umodes = GetAllowedOperOnlyModes(loctarg, MODETYPE_USER); - std::string cmodes = GetAllowedOperOnlyModes(loctarg, MODETYPE_CHANNEL); - context.Write("modeperms", "user=" + umodes + " channel=" + cmodes); + context.Write("chanmodeperms", GetAllowedOperOnlyModes(loctarg, MODETYPE_CHANNEL)); + context.Write("usermodeperms", GetAllowedOperOnlyModes(loctarg, MODETYPE_USER)); context.Write("commandperms", oper->AllowedOperCommands.ToString()); context.Write("permissions", oper->AllowedPrivs.ToString()); } -- cgit v1.3.1-10-gc9f91 From a7b52308dba32becb40522b76b1bfee8e37470fe Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 4 Feb 2019 15:26:53 +0000 Subject: m_check: improve the output of the member key. --- src/modules/m_check.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/modules/m_check.cpp') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 39f0d190a..3e9e46a3e 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -259,9 +259,9 @@ class CommandCheck : public Command * Unlike Asuka, I define a clone as coming from the same host. --w00t */ 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->GetDisplayedHost().c_str(), i->first->GetRealName().c_str())); + context.Write("member", InspIRCd::Format("%u %s%s (%s)", clonecount.global, + i->second->GetAllPrefixChars().c_str(), i->first->GetFullHost().c_str(), + i->first->GetRealName().c_str())); } const ModeParser::ListModeList& listmodes = ServerInstance->Modes->GetListModes(); -- cgit v1.3.1-10-gc9f91 From 0a229e70a5839b30d87f3585429d542db37c4cfd Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 4 Feb 2019 15:28:01 +0000 Subject: m_check: rename the timestamp key to createdat. --- src/modules/m_check.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/m_check.cpp') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 3e9e46a3e..65cccec5b 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -235,7 +235,7 @@ class CommandCheck : public Command else if (targchan) { /* /check on a channel */ - context.Write("timestamp", targchan->age); + context.Write("createdat", targchan->age); if (!targchan->topic.empty()) { -- cgit v1.3.1-10-gc9f91 From 1ad063eff9d62c3331da5b11326d80511f9d135b Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 4 Feb 2019 18:46:02 +0000 Subject: m_check: improve the output when showing list modes. Closes #1568. --- src/modules/m_check.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/modules/m_check.cpp') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 65cccec5b..58e71aadc 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -67,16 +67,21 @@ class CheckContext User* GetUser() const { return user; } - void DumpListMode(const ListModeBase::ModeList* list) + void DumpListMode(ListModeBase* mode, Channel* chan) { + const ListModeBase::ModeList* list = mode->GetList(chan); if (!list) return; - CheckContext::List modelist(*this, "modelist"); for (ListModeBase::ModeList::const_iterator i = list->begin(); i != list->end(); ++i) - modelist.Add(i->mask); - - modelist.Flush(); + { + CheckContext::List listmode(*this, "listmode"); + listmode.Add(ConvToStr(mode->GetModeChar())); + listmode.Add(i->mask); + listmode.Add(i->setter); + listmode.Add(FormatTime(i->time)); + listmode.Flush(); + } } void DumpExt(Extensible* ext) @@ -266,7 +271,7 @@ class CommandCheck : public Command const ModeParser::ListModeList& listmodes = ServerInstance->Modes->GetListModes(); for (ModeParser::ListModeList::const_iterator i = listmodes.begin(); i != listmodes.end(); ++i) - context.DumpListMode((*i)->GetList(targchan)); + context.DumpListMode(*i, targchan); context.DumpExt(targchan); } -- cgit v1.3.1-10-gc9f91