diff options
author | Sadie Powell <sadie@witchery.services> | 2021-02-01 14:13:36 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2021-02-01 14:34:00 +0000 |
commit | a235e4356074f10b6946ee4019769a707f4f6e1d (patch) | |
tree | 09598eb8e3f6cd4f9228ecf02490b549e4385736 /src | |
parent | b191657921845a26128e910bfff0f21251e98ee4 (diff) |
Move SSLINFO code for users to its own function and refactor.
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_sslinfo.cpp | 37 |
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]); } }; |