inspircd

A modular C++ IRC daemon (ircd). https://www.inspircd.org/
Log | Files | Refs | README

commit 18678c6a22f72152b7dacc356c791868b4e170c4
parent 4818b1bc1b0dd8560b0c83901aa33ecaf6fb1275
Author: Peter Powell <petpow@saberuk.com>
Date:   Mon, 28 Jan 2019 17:15:25 +0000

Add ParamMode::IsParameterSecret and remove special casing of keys.

Diffstat:
Minclude/channels.h | 6+++---
Minclude/parammode.h | 1+
Msrc/channels.cpp | 6+++---
Msrc/coremods/core_channel/cmode_k.cpp | 6++++++
Msrc/coremods/core_channel/core_channel.h | 1+
5 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/include/channels.h b/include/channels.h @@ -248,11 +248,11 @@ class CoreExport Channel : public Extensible void Write(ClientProtocol::EventProvider& protoevprov, ClientProtocol::Message& msg, char status = 0, const CUList& except_list = CUList()); /** Return the channel's modes with parameters. - * @param showkey If this is set to true, the actual key is shown, - * otherwise it is replaced with '&lt;KEY&gt;' + * @param showsecret If this is set to true, the value of secret parameters + * are shown, otherwise they are replaced with '&lt;name&gt;'. * @return The channel mode string */ - const char* ChanModes(bool showkey); + const char* ChanModes(bool showsecret); /** Get the value of a users prefix on this channel. * @param user The user to look up diff --git a/include/parammode.h b/include/parammode.h @@ -31,6 +31,7 @@ class CoreExport ParamModeBase : public ModeHandler ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& param, bool adding) CXX11_OVERRIDE; // Does nothing by default + virtual bool IsParameterSecret() { return false; } virtual void OnUnset(User* source, Channel* chan) { } virtual ModeAction OnSet(User* source, Channel* chan, std::string& param) = 0; virtual void GetParameter(Channel* chan, std::string& out) = 0; diff --git a/src/channels.cpp b/src/channels.cpp @@ -436,7 +436,7 @@ void Channel::Write(ClientProtocol::Event& protoev, char status, const CUList& e } } -const char* Channel::ChanModes(bool showkey) +const char* Channel::ChanModes(bool showsecret) { static std::string scratch; std::string sparam; @@ -455,9 +455,9 @@ const char* Channel::ChanModes(bool showkey) if (!pm) continue; - if (n == 'k' - 65 && !showkey) + if (pm->IsParameterSecret() && !showsecret) { - sparam += " <key>"; + sparam += " <" + pm->name + ">"; } else { diff --git a/src/coremods/core_channel/cmode_k.cpp b/src/coremods/core_channel/cmode_k.cpp @@ -87,3 +87,8 @@ ModeAction ModeChannelKey::OnSet(User* source, Channel* chan, std::string& param // Dummy function, never called return MODEACTION_DENY; } + +bool ModeChannelKey::IsParameterSecret() +{ + return true; +}+ \ No newline at end of file diff --git a/src/coremods/core_channel/core_channel.h b/src/coremods/core_channel/core_channel.h @@ -179,6 +179,7 @@ class ModeChannelKey : public ParamMode<ModeChannelKey, LocalStringExt> ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding) CXX11_OVERRIDE; void SerializeParam(Channel* chan, const std::string* key, std::string& out) ; ModeAction OnSet(User* source, Channel* chan, std::string& param) CXX11_OVERRIDE; + bool IsParameterSecret() CXX11_OVERRIDE; }; /** Channel mode +l