aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/m_check.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-11-29 04:52:42 +0000
committerGravatar Sadie Powell2022-11-29 04:52:42 +0000
commitf9ef385b890756e31871426502e52ebc66622894 (patch)
treee843804c28651b07863f76a4ad7c8f082dc0bc6d /src/modules/m_check.cpp
parentRefactor the internals of the oper system. (diff)
Move the oper statistics to core_oper and rewrite.
The numerics we used previously were not being used according to the RFC and every implementation has their own behaviour here which makes it hard for clients to do anything reasonable. Instead of this using the generic stats numeric makes a lot more sense.
Diffstat (limited to 'src/modules/m_check.cpp')
-rw-r--r--src/modules/m_check.cpp41
1 files changed, 4 insertions, 37 deletions
diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp
index 10ec6ca4b..839a5027b 100644
--- a/src/modules/m_check.cpp
+++ b/src/modules/m_check.cpp
@@ -134,39 +134,6 @@ class CommandCheck final
return ret;
}
- static std::string GetAllowedOperOnlyCommands(LocalUser* user)
- {
- std::string ret;
- for (const auto& [_, cmd] : ServerInstance->Parser.GetCommands())
- {
- if (cmd->access_needed == CmdAccess::OPERATOR && user->HasCommandPermission(cmd->name))
- ret += cmd->name + " ";
- }
- if (!ret.empty())
- ret.pop_back();
- return ret;
- }
-
- static std::string GetAllowedOperOnlyModes(LocalUser* user, ModeType modetype)
- {
- std::string ret;
- for (const auto& [_, mh] : ServerInstance->Modes.GetModes(modetype))
- {
- if ((mh->NeedsOper()) && (user->HasModePermission(mh)))
- ret.push_back(mh->GetModeChar());
- }
- return ret;
- }
-
- static std::string GetAllowedOperOnlySnomasks(LocalUser* user)
- {
- std::string ret;
- for (unsigned char sno = 'A'; sno <= 'z'; ++sno)
- if (ServerInstance->SNO.IsSnomaskUsable(sno) && user->HasSnomaskPermission(sno))
- ret.push_back(sno);
- return ret;
- }
-
public:
CommandCheck(Module* parent)
: Command(parent,"CHECK", 1)
@@ -226,10 +193,10 @@ public:
context.Write("opertype", targetuser->oper->GetType());
if (localtarget)
{
- context.Write("chanmodeperms", GetAllowedOperOnlyModes(localtarget, MODETYPE_CHANNEL));
- context.Write("usermodeperms", GetAllowedOperOnlyModes(localtarget, MODETYPE_USER));
- context.Write("snomaskperms", GetAllowedOperOnlySnomasks(localtarget));
- context.Write("commandperms", GetAllowedOperOnlyCommands(localtarget));
+ context.Write("chanmodeperms", localtarget->oper->GetModes(MODETYPE_CHANNEL));
+ context.Write("usermodeperms", localtarget->oper->GetModes(MODETYPE_USER));
+ context.Write("snomaskperms", localtarget->oper->GetSnomasks());
+ context.Write("commandperms", localtarget->oper->GetCommands());
context.Write("permissions", localtarget->oper->GetPrivileges());
}
}