diff options
| author | 2022-06-23 14:35:42 +0100 | |
|---|---|---|
| committer | 2022-06-23 14:35:42 +0100 | |
| commit | 409d266100457c2033281b96cebacd5179fadbef (patch) | |
| tree | bd140ddf743b95c13032b5acfbc199bb4d965c8b /src/modules/m_userip.cpp | |
| parent | Fix inconsistencies between USERHOST and USERIP. (diff) | |
Fix more inconsistencies with USERIP.
- Use a dummy value instead of erroring if the viewer does not have
the privs to see the IP address (fixes UnrealIRCd compat).
- Respect the hideoper mode when building the USERIP response.
Diffstat (limited to 'src/modules/m_userip.cpp')
| -rw-r--r-- | src/modules/m_userip.cpp | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/modules/m_userip.cpp b/src/modules/m_userip.cpp index 11fb6cd39..6edb82fbb 100644 --- a/src/modules/m_userip.cpp +++ b/src/modules/m_userip.cpp @@ -30,8 +30,13 @@ */ class CommandUserip : public Command { + private: + UserModeReference hideopermode; + public: - CommandUserip(Module* Creator) : Command(Creator,"USERIP", 1) + CommandUserip(Module* Creator) + : Command(Creator,"USERIP", 1) + , hideopermode(Creator, "hideoper") { allow_empty_last_param = false; syntax = "<nick> [<nick>]+"; @@ -39,9 +44,9 @@ class CommandUserip : public Command CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE { + const bool has_privs = user->HasPrivPermission("users/auspex"); + std::string retbuf; - bool checked_privs = false; - bool has_privs = false; size_t paramcount = std::min<size_t>(parameters.size(), 5); for (size_t i = 0; i < paramcount; ++i) @@ -49,28 +54,21 @@ class CommandUserip : public Command User *u = ServerInstance->FindNickOnly(parameters[i]); if ((u) && (u->registered == REG_ALL)) { - // Anyone may query their own IP - if (u != user) - { - if (!checked_privs) - { - // Do not trigger the insufficient privileges message more than once - checked_privs = true; - has_privs = user->HasPrivPermission("users/auspex"); - if (!has_privs) - user->WriteNumeric(ERR_NOPRIVILEGES, "Permission Denied - You do not have the required operator privileges"); - } + retbuf += u->nick; - if (!has_privs) - continue; + if (u->IsOper()) + { + // XXX: +H hidden opers must not be shown as opers + if ((u == user) || (has_privs) || (!u->IsModeSet(hideopermode))) + retbuf += '*'; } - retbuf = retbuf + u->nick + (u->IsOper() ? "*" : "") + "="; - if (u->IsAway()) - retbuf += "-"; - else - retbuf += "+"; - retbuf += u->ident + "@" + u->GetIPString() + " "; + retbuf += '='; + retbuf += (u->IsAway() ? '-' : '+'); + retbuf += u->ident; + retbuf += '@'; + retbuf += (u == user || has_privs ? u->GetIPString() : "255.255.255.255"); + retbuf += ' '; } } |
