From: Sadie Powell Date: Mon, 1 Feb 2021 14:13:36 +0000 (+0000) Subject: Move SSLINFO code for users to its own function and refactor. X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=a235e4356074f10b6946ee4019769a707f4f6e1d;p=user%2Fhenk%2Fcode%2Finspircd.git Move SSLINFO code for users to its own function and refactor. --- 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]); } };