From 219d0fa1a64c5c2c155942ebc52543dd956519b1 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 30 Jan 2021 16:29:01 +0000 Subject: [PATCH] Fix a few issues with SERVLIST. - Implement support for service type matching based on the service oper type. This isn't the same as irc2 but its close enough. - Fix erroneously sending the mask in the field. This field is for the service name mask not the service distribution mask. --- src/coremods/core_info/cmd_servlist.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/coremods/core_info/cmd_servlist.cpp b/src/coremods/core_info/cmd_servlist.cpp index f400124d2..9490f7280 100644 --- a/src/coremods/core_info/cmd_servlist.cpp +++ b/src/coremods/core_info/cmd_servlist.cpp @@ -32,28 +32,32 @@ CommandServList::CommandServList(Module* parent) , invisiblemode(parent, "invisible") { allow_empty_last_param = false; - syntax = "[]"; + syntax = "[ []]"; } CmdResult CommandServList::HandleLocal(LocalUser* user, const Params& parameters) { const std::string& mask = parameters.empty() ? "*" : parameters[0]; + const bool has_type = parameters.size() > 1; for (UserManager::ULineList::const_iterator iter = ServerInstance->Users.all_ulines.begin(); iter != ServerInstance->Users.all_ulines.end(); ++iter) { User* uline = *iter; if (uline->IsModeSet(invisiblemode) || !InspIRCd::Match(uline->nick, mask)) continue; + if (has_type && (!user->IsOper() || !InspIRCd::Match(user->oper->name, parameters[2 ]))) + continue; + Numeric::Numeric numeric(RPL_SERVLIST); numeric .push(uline->nick) .push(uline->server->GetName()) - .push(mask) - .push(0) + .push("*") + .push(user->IsOper() ? user->oper->name : "*") .push(0) .push(uline->GetRealName()); user->WriteNumeric(numeric); } - user->WriteNumeric(RPL_SERVLISTEND, mask, 0, "End of service listing"); + user->WriteNumeric(RPL_SERVLISTEND, mask, has_type ? parameters[1] : "*", "End of service listing"); return CMD_SUCCESS; } -- 2.39.2