]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix a few issues with SERVLIST.
authorSadie Powell <sadie@witchery.services>
Sat, 30 Jan 2021 16:29:01 +0000 (16:29 +0000)
committerSadie Powell <sadie@witchery.services>
Sat, 30 Jan 2021 16:32:43 +0000 (16:32 +0000)
- 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 <mask> field. This field
  is for the service name mask not the service distribution mask.

src/coremods/core_info/cmd_servlist.cpp

index f400124d2b1e7c02e7ecccd14d7e729d681e127b..9490f7280428c23192f6fe15e6e00be2974c556a 100644 (file)
@@ -32,28 +32,32 @@ CommandServList::CommandServList(Module* parent)
        , invisiblemode(parent, "invisible")
 {
        allow_empty_last_param = false;
-       syntax = "[<mask>]";
+       syntax = "[<mask> [<type>]]";
 }
 
 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;
 }