summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2021-02-01 14:13:36 +0000
committerSadie Powell <sadie@witchery.services>2021-02-01 14:34:00 +0000
commita235e4356074f10b6946ee4019769a707f4f6e1d (patch)
tree09598eb8e3f6cd4f9228ecf02490b549e4385736
parentb191657921845a26128e910bfff0f21251e98ee4 (diff)
Move SSLINFO code for users to its own function and refactor.
-rw-r--r--src/modules/m_sslinfo.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp
index 2809731be..d51a691c6 100644
--- a/src/modules/m_sslinfo.cpp
+++ b/src/modules/m_sslinfo.cpp
@@ -174,6 +174,25 @@ class CommandSSLInfo : public SplitCommand
}
}
+ CmdResult HandleUser(LocalUser* source, const std::string& nick)
+ {
+ User* target = ServerInstance->FindNickOnly(nick);
+ if (!target || target->registered != REG_ALL)
+ {
+ source->WriteNumeric(Numerics::NoSuchNick(nick));
+ return CMD_FAILURE;
+ }
+
+ if (operonlyfp && !source->IsOper() && source != target)
+ {
+ source->WriteNumeric(ERR_NOPRIVILEGES, "You must be a server operator to view TLS (SSL) client certificate information for other users.");
+ return CMD_FAILURE;
+ }
+
+ HandleUserInternal(source, target, true);
+ return CMD_SUCCESS;
+ }
+
CmdResult HandleChannel(LocalUser* source, const std::string& channel)
{
Channel* chan = ServerInstance->FindChan(channel);
@@ -226,22 +245,8 @@ class CommandSSLInfo : public SplitCommand
{
if (ServerInstance->IsChannel(parameters[0]))
return HandleChannel(user, parameters[0]);
-
- User* target = ServerInstance->FindNickOnly(parameters[0]);
- if ((!target) || (target->registered != REG_ALL))
- {
- user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
- return CMD_FAILURE;
- }
-
- if (operonlyfp && !user->IsOper() && target != user)
- {
- user->WriteNotice("*** You cannot view TLS (SSL) client certificate information for other users");
- return CMD_FAILURE;
- }
-
- HandleUserInternal(user, target, true);
- return CMD_SUCCESS;
+ else
+ return HandleUser(user, parameters[0]);
}
};