From 8389fbba6d92dec84745e5b8db4739f97561585e Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 22 Jan 2023 22:01:25 +0000 Subject: Replace ModeAction with bool. This enum is functionally the same as bool but with weird semantics. --- src/coremods/core_channel/cmode_k.cpp | 16 ++++---- src/coremods/core_channel/core_channel.h | 6 +-- src/coremods/core_channel/modes.cpp | 6 +-- src/coremods/core_oper/core_oper.h | 4 +- src/coremods/core_oper/umode_o.cpp | 8 ++-- src/coremods/core_oper/umode_s.cpp | 8 ++-- src/listmode.cpp | 14 +++---- src/mode.cpp | 64 +++++++++++++++----------------- src/modules/m_anticaps.cpp | 6 +-- src/modules/m_chanhistory.cpp | 10 ++--- src/modules/m_cloak.cpp | 14 +++---- src/modules/m_deaf.cpp | 16 ++++---- src/modules/m_delayjoin.cpp | 6 +-- src/modules/m_delaymsg.cpp | 6 +-- src/modules/m_hideoper.cpp | 8 ++-- src/modules/m_joinflood.cpp | 8 ++-- src/modules/m_kicknorejoin.cpp | 6 +-- src/modules/m_messageflood.cpp | 8 ++-- src/modules/m_nickflood.cpp | 8 ++-- src/modules/m_override.cpp | 6 +-- src/modules/m_permchannels.cpp | 6 +-- src/modules/m_redirect.cpp | 10 ++--- src/modules/m_repeat.cpp | 10 ++--- src/modules/m_services.cpp | 8 ++-- src/modules/m_servprotect.cpp | 6 +-- src/modules/m_sslmodes.cpp | 22 +++++------ 26 files changed, 143 insertions(+), 147 deletions(-) (limited to 'src') diff --git a/src/coremods/core_channel/cmode_k.cpp b/src/coremods/core_channel/cmode_k.cpp index 4a98920da..af86e2eb2 100644 --- a/src/coremods/core_channel/cmode_k.cpp +++ b/src/coremods/core_channel/cmode_k.cpp @@ -39,25 +39,25 @@ ModeChannelKey::ModeChannelKey(Module* Creator) syntax = ""; } -ModeAction ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, Modes::Change& change) +bool ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, Modes::Change& change) { const std::string* key = ext.Get(channel); bool exists = (key != nullptr); if (IS_LOCAL(source)) { if (exists == change.adding) - return MODEACTION_DENY; + return false; if (exists && (change.param != *key)) { /* Key is currently set and the correct key wasn't given */ source->WriteNumeric(ERR_KEYSET, channel->name, "Channel key already set"); - return MODEACTION_DENY; + return false; } } else { if (exists && change.adding && change.param == *key) { /* no-op, don't show */ - return MODEACTION_DENY; + return false; } } @@ -76,7 +76,7 @@ ModeAction ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, M // If the password is empty here then it only consisted of commas. This is not // acceptable so we reject the mode change. if (change.param.empty()) - return MODEACTION_DENY; + return false; ext.Set(channel, change.param); } @@ -84,7 +84,7 @@ ModeAction ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, M ext.Unset(channel); channel->SetMode(this, change.adding); - return MODEACTION_ALLOW; + return true; } void ModeChannelKey::SerializeParam(Channel* chan, const std::string* key, std::string& out) @@ -92,10 +92,10 @@ void ModeChannelKey::SerializeParam(Channel* chan, const std::string* key, std:: out += *key; } -ModeAction ModeChannelKey::OnSet(User* source, Channel* chan, std::string& param) +bool ModeChannelKey::OnSet(User* source, Channel* chan, std::string& param) { // Dummy function, never called - return MODEACTION_DENY; + return false; } bool ModeChannelKey::IsParameterSecret() diff --git a/src/coremods/core_channel/core_channel.h b/src/coremods/core_channel/core_channel.h index caa4adf99..1e626aa68 100644 --- a/src/coremods/core_channel/core_channel.h +++ b/src/coremods/core_channel/core_channel.h @@ -115,9 +115,9 @@ class ModeChannelKey final public: std::string::size_type maxkeylen; ModeChannelKey(Module* Creator); - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override; + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override; void SerializeParam(Channel* chan, const std::string* key, std::string& out); - ModeAction OnSet(User* source, Channel* chan, std::string& param) override; + bool OnSet(User* source, Channel* chan, std::string& param) override; bool IsParameterSecret() override; }; @@ -128,7 +128,7 @@ public: ModeChannelLimit(Module* Creator); bool ResolveModeConflict(const std::string& their_param, const std::string& our_param, Channel* channel) override; void SerializeParam(Channel* chan, intptr_t n, std::string& out); - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override; + bool OnSet(User* source, Channel* channel, std::string& parameter) override; }; class ModeChannelOp final diff --git a/src/coremods/core_channel/modes.cpp b/src/coremods/core_channel/modes.cpp index f8c586c1b..c66b4ef16 100644 --- a/src/coremods/core_channel/modes.cpp +++ b/src/coremods/core_channel/modes.cpp @@ -55,7 +55,7 @@ bool ModeChannelLimit::ResolveModeConflict(const std::string& their_param, const return ConvToNum(their_param) < ConvToNum(our_param); } -ModeAction ModeChannelLimit::OnSet(User* user, Channel* chan, std::string& parameter) +bool ModeChannelLimit::OnSet(User* user, Channel* chan, std::string& parameter) { size_t limit = ConvToNum(parameter); if (limit < 1 || limit > INTPTR_MAX) @@ -64,7 +64,7 @@ ModeAction ModeChannelLimit::OnSet(User* user, Channel* chan, std::string& param { // If the setter is local then we can safely just reject this here. user->WriteNumeric(Numerics::InvalidModeParameter(chan, this, parameter)); - return MODEACTION_DENY; + return false; } else { @@ -75,7 +75,7 @@ ModeAction ModeChannelLimit::OnSet(User* user, Channel* chan, std::string& param } ext.Set(chan, limit); - return MODEACTION_ALLOW; + return true; } void ModeChannelLimit::SerializeParam(Channel* chan, intptr_t limit, std::string& out) diff --git a/src/coremods/core_oper/core_oper.h b/src/coremods/core_oper/core_oper.h index 6878b33b5..41115f83b 100644 --- a/src/coremods/core_oper/core_oper.h +++ b/src/coremods/core_oper/core_oper.h @@ -105,7 +105,7 @@ private: public: ModeUserServerNoticeMask(Module* Creator); - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override; + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override; /** Create a displayable mode string of the snomasks set on a given user * @param user The user whose notice masks to format @@ -119,5 +119,5 @@ class ModeUserOperator final { public: ModeUserOperator(Module* Creator); - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override; + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override; }; diff --git a/src/coremods/core_oper/umode_o.cpp b/src/coremods/core_oper/umode_o.cpp index 28a397219..f0373e7b0 100644 --- a/src/coremods/core_oper/umode_o.cpp +++ b/src/coremods/core_oper/umode_o.cpp @@ -31,15 +31,15 @@ ModeUserOperator::ModeUserOperator(Module* Creator) { } -ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, Modes::Change& change) +bool ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, Modes::Change& change) { /* Only opers can execute this class at all */ if (!source->server->IsService() && !source->IsOper()) - return MODEACTION_DENY; + return false; /* Not even opers can GIVE the +o mode, only take it away */ if (change.adding) - return MODEACTION_DENY; + return false; /* Set the bitfields. * Note that oper status is only given in User::Oper() @@ -51,5 +51,5 @@ ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, Mo ServerInstance->SNO.WriteToSnoMask(snomask, "User %s de-opered (by %s)", dest->nick.c_str(), source->nick.c_str()); dest->OperLogout(); - return MODEACTION_ALLOW; + return true; } diff --git a/src/coremods/core_oper/umode_s.cpp b/src/coremods/core_oper/umode_s.cpp index b6534f0a8..c7562a744 100644 --- a/src/coremods/core_oper/umode_s.cpp +++ b/src/coremods/core_oper/umode_s.cpp @@ -33,14 +33,14 @@ ModeUserServerNoticeMask::ModeUserServerNoticeMask(Module* Creator) syntax = "(+|-)|*"; } -ModeAction ModeUserServerNoticeMask::OnModeChange(User* source, User* dest, Channel*, Modes::Change& change) +bool ModeUserServerNoticeMask::OnModeChange(User* source, User* dest, Channel*, Modes::Change& change) { if (change.adding) { dest->SetMode(this, true); // Process the parameter (remove chars we don't understand, remove redundant chars, etc.) change.param = ProcessNoticeMasks(dest, change.param); - return MODEACTION_ALLOW; + return true; } else { @@ -48,12 +48,12 @@ ModeAction ModeUserServerNoticeMask::OnModeChange(User* source, User* dest, Chan { dest->SetMode(this, false); dest->snomasks.reset(); - return MODEACTION_ALLOW; + return true; } } // Mode not set and trying to unset, deny - return MODEACTION_DENY; + return false; } std::string ModeUserServerNoticeMask::GetUserParameter(const User* user) const diff --git a/src/listmode.cpp b/src/listmode.cpp index 2e20c527f..4fd77d7f0 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -155,14 +155,14 @@ unsigned long ListModeBase::GetLowerLimit() return limit; } -ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, Modes::Change& change) +bool ListModeBase::OnModeChange(User* source, User*, Channel* channel, Modes::Change& change) { LocalUser* lsource = IS_LOCAL(source); if (change.adding) { // Try to canonicalise the parameter locally. if (lsource && !ValidateParam(lsource, channel, change.param)) - return MODEACTION_DENY; + return false; ChanData* cd = extItem.Get(channel); if (cd) @@ -176,7 +176,7 @@ ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, Mod if (lsource) TellAlreadyOnList(lsource, channel, change.param); - return MODEACTION_DENY; + return false; } } else @@ -190,12 +190,12 @@ ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, Mod { // The list size might be 0 so we have to check even if just created. TellListTooLong(lsource, channel, change.param); - return MODEACTION_DENY; + return false; } // Add the new entry to the list. cd->list.emplace_back(change.param, change.set_by.value_or(source->nick), change.set_at.value_or(ServerInstance->Time())); - return MODEACTION_ALLOW; + return true; } else { @@ -209,14 +209,14 @@ ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, Mod continue; // Doesn't match the proposed removal. stdalgo::vector::swaperase(cd->list, it); - return MODEACTION_ALLOW; + return true; } } if (lsource) TellNotSet(lsource, channel, change.param); - return MODEACTION_DENY; + return false; } } diff --git a/src/mode.cpp b/src/mode.cpp index f5b9f479d..1012b2dbf 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -72,9 +72,9 @@ ModResult ModeHandler::AccessCheck(User*, Channel*, Modes::Change&) return MOD_RES_PASSTHRU; } -ModeAction ModeHandler::OnModeChange(User*, User*, Channel*, Modes::Change&) +bool ModeHandler::OnModeChange(User*, User*, Channel*, Modes::Change&) { - return MODEACTION_DENY; + return false; } void ModeHandler::DisplayList(User*, Channel*) @@ -116,12 +116,12 @@ void ModeHandler::RegisterService() ServerInstance->Modules.AddReferent((GetModeType() == MODETYPE_CHANNEL ? "mode/" : "umode/") + name, this); } -ModeAction SimpleUserMode::OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) +bool SimpleUserMode::OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) { /* We're either trying to add a mode we already have or remove a mode we don't have, deny. */ if (dest->IsModeSet(this) == change.adding) - return MODEACTION_DENY; + return false; /* adding will be either true or false, depending on if we are adding or removing the mode, since we already checked @@ -131,15 +131,15 @@ ModeAction SimpleUserMode::OnModeChange(User* source, User* dest, Channel* chann remove the mode */ dest->SetMode(this, change.adding); - return MODEACTION_ALLOW; + return true; } -ModeAction SimpleChannelMode::OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) +bool SimpleChannelMode::OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) { /* We're either trying to add a mode we already have or remove a mode we don't have, deny. */ if (channel->IsModeSet(this) == change.adding) - return MODEACTION_DENY; + return false; /* adding will be either true or false, depending on if we are adding or removing the mode, since we already checked @@ -149,7 +149,7 @@ ModeAction SimpleChannelMode::OnModeChange(User* source, User* dest, Channel* ch remove the mode */ channel->SetMode(this, change.adding); - return MODEACTION_ALLOW; + return true; } ModeWatcher::ModeWatcher(Module* Creator, const std::string& modename, ModeType type) @@ -190,7 +190,7 @@ ModResult PrefixMode::AccessCheck(User* src, Channel*, Modes::Change& change) return MOD_RES_PASSTHRU; } -ModeAction PrefixMode::OnModeChange(User* source, User*, Channel* chan, Modes::Change& change) +bool PrefixMode::OnModeChange(User* source, User*, Channel* chan, Modes::Change& change) { User* target; if (IS_LOCAL(source)) @@ -201,15 +201,15 @@ ModeAction PrefixMode::OnModeChange(User* source, User*, Channel* chan, Modes::C if (!target) { source->WriteNumeric(Numerics::NoSuchNick(change.param)); - return MODEACTION_DENY; + return false; } Membership* memb = chan->GetUser(target); if (!memb) - return MODEACTION_DENY; + return false; change.param = target->nick; - return (memb->SetPrefix(this, change.adding) ? MODEACTION_ALLOW : MODEACTION_DENY); + return memb->SetPrefix(this, change.adding); } void PrefixMode::Update(ModeHandler::Rank rank, ModeHandler::Rank setrank, ModeHandler::Rank unsetrank, bool selfrm) @@ -220,15 +220,15 @@ void PrefixMode::Update(ModeHandler::Rank rank, ModeHandler::Rank setrank, ModeH selfremove = selfrm; } -ModeAction ParamModeBase::OnModeChange(User* source, User*, Channel* chan, Modes::Change& change) +bool ParamModeBase::OnModeChange(User* source, User*, Channel* chan, Modes::Change& change) { if (change.adding) { if (chan->GetModeParameter(this) == change.param) - return MODEACTION_DENY; + return false; - if (OnSet(source, chan, change.param) != MODEACTION_ALLOW) - return MODEACTION_DENY; + if (!OnSet(source, chan, change.param)) + return false; chan->SetMode(this, true); @@ -239,14 +239,14 @@ ModeAction ParamModeBase::OnModeChange(User* source, User*, Channel* chan, Modes else { if (!chan->IsModeSet(this)) - return MODEACTION_DENY; + return false; this->OnUnsetInternal(source, chan); chan->SetMode(this, false); } - return MODEACTION_ALLOW; + return true; } -ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Modes::Change& mcitem, bool SkipACL) +bool ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Modes::Change& mcitem, bool SkipACL) { ModeType type = chan ? MODETYPE_CHANNEL : MODETYPE_USER; @@ -261,7 +261,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode FIRST_MOD_RESULT(OnRawMode, MOD_RESULT, (user, chan, mcitem)); if (IS_LOCAL(user) && (MOD_RESULT == MOD_RES_DENY)) - return MODEACTION_DENY; + return false; const char modechar = mh->GetModeChar(); @@ -270,7 +270,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode MOD_RESULT = mh->AccessCheck(user, chan, mcitem); if (MOD_RESULT == MOD_RES_DENY) - return MODEACTION_DENY; + return false; if (MOD_RESULT == MOD_RES_PASSTHRU) { ModeHandler::Rank neededrank = mh->GetLevelRequired(mcitem.adding); @@ -279,7 +279,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode { user->WriteNumeric(Numerics::ChannelPrivilegesNeeded(chan, neededrank, InspIRCd::Format("%s channel mode %c (%s)", mcitem.adding ? "set" : "unset", mh->GetModeChar(), mh->name.c_str()))); - return MODEACTION_DENY; + return false; } } } @@ -290,11 +290,11 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode if (mw->GetModeType() == type) { if (!mw->BeforeMode(user, targetuser, chan, mcitem)) - return MODEACTION_DENY; + return false; // A module whacked the parameter completely, and there was one. Abort. if ((needs_param) && (mcitem.param.empty())) - return MODEACTION_DENY; + return false; } } @@ -311,17 +311,15 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Only operators may %sset %s mode %c", mcitem.adding ? "" : "un", type == MODETYPE_CHANNEL ? "channel" : "user", modechar)); } - return MODEACTION_DENY; + return false; } /* Call the handler for the mode */ - ModeAction ma = mh->OnModeChange(user, targetuser, chan, mcitem); + if (!mh->OnModeChange(user, targetuser, chan, mcitem)) + return false; if ((needs_param) && (mcitem.param.empty())) - return MODEACTION_DENY; - - if (ma != MODEACTION_ALLOW) - return ma; + return false; for (const auto& [_, mw] : insp::equal_range(modewatchermap, mh->name)) { @@ -329,7 +327,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode mw->AfterMode(user, targetuser, chan, mcitem); } - return MODEACTION_ALLOW; + return true; } void ModeParser::ModeParamsToChangeList(User* user, ModeType type, const std::vector& parameters, Modes::ChangeList& changelist, size_t beginindex, size_t endindex) @@ -441,9 +439,7 @@ size_t ModeParser::ProcessSingle(User* user, Channel* targetchannel, User* targe continue; } - ModeAction ma = TryMode(user, targetuser, targetchannel, item, (!(flags & MODE_CHECKACCESS))); - - if (ma != MODEACTION_ALLOW) + if (!TryMode(user, targetuser, targetchannel, item, (!(flags & MODE_CHECKACCESS)))) continue; LastChangeList.push(mh, item.adding, item.param); diff --git a/src/modules/m_anticaps.cpp b/src/modules/m_anticaps.cpp index 319e85cea..b7a4d4caa 100644 --- a/src/modules/m_anticaps.cpp +++ b/src/modules/m_anticaps.cpp @@ -111,7 +111,7 @@ public: syntax = "{ban|block|mute|kick|kickban}::"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { irc::sepstream stream(parameter, ':'); AntiCapsMethod method; @@ -122,11 +122,11 @@ public: if (!ParseMethod(stream, method) || !ParseMinimumLength(stream, minlen) || !ParsePercent(stream, percent)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } ext.SetFwd(channel, method, minlen, percent); - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const AntiCapsSettings* acs, std::string& out) diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index 9e058c629..4a33451b8 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -87,20 +87,20 @@ public: syntax = ":"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { std::string::size_type colon = parameter.find(':'); if (colon == std::string::npos) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } std::string duration(parameter, colon+1); if ((IS_LOCAL(source)) && ((duration.length() > 10) || (!InspIRCd::IsValidDuration(duration)))) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } unsigned long len = ConvToNum(parameter.substr(0, colon)); @@ -108,7 +108,7 @@ public: if (!InspIRCd::Duration(duration, time) || len == 0 || (len > maxlines && IS_LOCAL(source))) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } if (len > maxlines) len = maxlines; @@ -128,7 +128,7 @@ public: { ext.SetFwd(channel, len, time); } - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const HistoryList* history, std::string& out) diff --git a/src/modules/m_cloak.cpp b/src/modules/m_cloak.cpp index 50bb95ec4..8c02ffc1e 100644 --- a/src/modules/m_cloak.cpp +++ b/src/modules/m_cloak.cpp @@ -146,7 +146,7 @@ public: return cloaks->empty() ? nullptr : cloaks; } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { // For remote users blindly allow this LocalUser* user = IS_LOCAL(dest); @@ -155,12 +155,12 @@ public: // Remote setters broadcast mode before host while local setters do the opposite. active = IS_LOCAL(source) ? change.adding : !change.adding; dest->SetMode(this, change.adding); - return MODEACTION_ALLOW; + return true; } // Don't allow the mode change if its a no-op or a spam change. if (change.adding == user->IsModeSet(this) || CheckSpam(user)) - return MODEACTION_DENY; + return false; // Penalise changing the mode to avoid spam. if (source == dest) @@ -171,7 +171,7 @@ public: // Remove the mode and restore their real host. user->SetMode(this, false); user->ChangeDisplayedHost(user->GetRealHost()); - return MODEACTION_ALLOW; + return true; } // If a user is not fully connected and their displayed hostname is @@ -179,7 +179,7 @@ public: // them by services. We should avoid automatically setting cloak on // them in this case. if (!user->IsFullyConnected() && user->GetRealHost() != user->GetDisplayedHost()) - return MODEACTION_DENY; + return false; auto* cloaks = GetCloaks(user); if (cloaks) @@ -187,9 +187,9 @@ public: // We were able to generate cloaks for this user. user->ChangeDisplayedHost(cloaks->front()); user->SetMode(this, true); - return MODEACTION_ALLOW; + return true; } - return MODEACTION_DENY; + return false; } }; diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp index d8ee9bfcf..68c926697 100644 --- a/src/modules/m_deaf.cpp +++ b/src/modules/m_deaf.cpp @@ -38,15 +38,15 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { - if (SimpleUserMode::OnModeChange(source, dest, channel, change) == MODEACTION_ALLOW) + if (SimpleUserMode::OnModeChange(source, dest, channel, change) == true) { dest->WriteNotice("*** You have enabled user mode +d, deaf mode. This mode means you WILL NOT receive any messages from any channels you are in. If you did NOT mean to do this, use /mode " + dest->nick + " -d."); - return MODEACTION_ALLOW; + return true; } - return MODEACTION_DENY; + return false; } }; @@ -60,15 +60,15 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { - if (SimpleUserMode::OnModeChange(source, dest, channel, change) == MODEACTION_ALLOW) + if (SimpleUserMode::OnModeChange(source, dest, channel, change) == true) { dest->WriteNotice("*** You have enabled user mode +D, private deaf mode. This mode means you WILL NOT receive any messages and notices from any nicks. If you did NOT mean to do this, use /mode " + dest->nick + " -D."); - return MODEACTION_ALLOW; + return true; } - return MODEACTION_DENY; + return false; } }; diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp index 96c3b5185..c6d6ae249 100644 --- a/src/modules/m_delayjoin.cpp +++ b/src/modules/m_delayjoin.cpp @@ -47,7 +47,7 @@ public: ranktoset = ranktounset = OP_VALUE; } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { if (SimpleChannelMode::OnModeChange(source, dest, channel, change)) { @@ -57,9 +57,9 @@ public: */ for (const auto& [member, _] : channel->GetUsers()) RevealUser(member, channel); - return MODEACTION_ALLOW; + return true; } - return MODEACTION_DENY; + return false; } void RevealUser(User* user, Channel* chan); diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp index fedc45b6f..25d744656 100644 --- a/src/modules/m_delaymsg.cpp +++ b/src/modules/m_delaymsg.cpp @@ -44,7 +44,7 @@ public: return ConvToNum(their_param) < ConvToNum(our_param); } - ModeAction OnSet(User* source, Channel* chan, std::string& parameter) override; + bool OnSet(User* source, Channel* chan, std::string& parameter) override; void OnUnset(User* source, Channel* chan) override; void SerializeParam(Channel* chan, intptr_t n, std::string& out) @@ -78,7 +78,7 @@ public: void ReadConfig(ConfigStatus& status) override; }; -ModeAction DelayMsgMode::OnSet(User* source, Channel* chan, std::string& parameter) +bool DelayMsgMode::OnSet(User* source, Channel* chan, std::string& parameter) { // Setting a new limit, sanity check intptr_t limit = ConvToNum(parameter); @@ -86,7 +86,7 @@ ModeAction DelayMsgMode::OnSet(User* source, Channel* chan, std::string& paramet limit = 1; ext.Set(chan, limit); - return MODEACTION_ALLOW; + return true; } void DelayMsgMode::OnUnset(User* source, Channel* chan) diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index 884e1c2b4..a8bf2947a 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -44,17 +44,17 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { - if (SimpleUserMode::OnModeChange(source, dest, channel, change) == MODEACTION_DENY) - return MODEACTION_DENY; + if (SimpleUserMode::OnModeChange(source, dest, channel, change) == false) + return false; if (change.adding) opercount++; else opercount--; - return MODEACTION_ALLOW; + return true; } }; diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index d31053421..b6c5afb3d 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -101,13 +101,13 @@ public: syntax = ":"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { std::string::size_type colon = parameter.find(':'); if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } /* Set up the flood parameters for this channel */ @@ -116,11 +116,11 @@ public: if ((njoins<1) || (nsecs<1)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } ext.SetFwd(channel, nsecs, njoins); - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const joinfloodsettings* jfs, std::string& out) diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index 1bdd8f7da..588adf73c 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -102,20 +102,20 @@ public: syntax = ""; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { unsigned int v = ConvToNum(parameter); if (v <= 0) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } if (IS_LOCAL(source) && v > max) v = max; ext.Set(channel, v); - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const KickRejoinData* krd, std::string& out) diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index ff919c4bc..324331275 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -78,13 +78,13 @@ public: syntax = "[*]:"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { std::string::size_type colon = parameter.find(':'); if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } /* Set up the flood parameters for this channel */ @@ -95,11 +95,11 @@ public: if ((nlines<2) || (nsecs<1)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } ext.SetFwd(channel, ban, nsecs, nlines); - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const floodsettings* fs, std::string& out) diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index 37e4a56c0..7bd3fcc14 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -94,13 +94,13 @@ public: syntax = ":"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { std::string::size_type colon = parameter.find(':'); if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } /* Set up the flood parameters for this channel */ @@ -110,11 +110,11 @@ public: if ((nnicks<1) || (nsecs<1)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } ext.SetFwd(channel, nsecs, nnicks); - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const nickfloodsettings* nfs, std::string& out) diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index 6f4e75605..5c1125340 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -76,10 +76,10 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { - ModeAction res = SimpleUserMode::OnModeChange(source, dest, channel, change); - if (change.adding && res == MODEACTION_ALLOW && IS_LOCAL(dest) && timeout) + bool res = SimpleUserMode::OnModeChange(source, dest, channel, change); + if (change.adding && res && IS_LOCAL(dest) && timeout) ext.Set(dest, new UnsetTimer(IS_LOCAL(dest), timeout, *this)); return res; } diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index 4482795e3..c9beae1f1 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -40,17 +40,17 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { if (SimpleChannelMode::OnModeChange(source, dest, channel, change)) { if (!change.adding) channel->CheckDestroy(); - return MODEACTION_ALLOW; + return true; } - return MODEACTION_DENY; + return false; } void SetOperOnly(bool value) diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 8f89836c6..521ccb091 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -41,14 +41,14 @@ public: syntax = ""; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { if (IS_LOCAL(source)) { if (!ServerInstance->Channels.IsChannel(parameter)) { source->WriteNumeric(Numerics::NoSuchChannel(parameter)); - return MODEACTION_DENY; + return false; } } @@ -58,12 +58,12 @@ public: if (!c) { source->WriteNumeric(690, InspIRCd::Format("Target channel %s must exist to be set as a redirect.", parameter.c_str())); - return MODEACTION_DENY; + return false; } else if (c->GetPrefixValue(source) < OP_VALUE) { source->WriteNumeric(690, InspIRCd::Format("You must be opped on %s to set it as a redirect.", parameter.c_str())); - return MODEACTION_DENY; + return false; } } @@ -72,7 +72,7 @@ public: * now catch +L looping in PreJoin. Remove it, since O(n) logic makes me sad, and we catch it anyway. :) -- w00t */ ext.Set(channel, parameter); - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const std::string* str, std::string& out) diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index 0268850bb..85953c851 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -150,29 +150,29 @@ public: MemberInfoExt.Unset(memb); } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { ChannelSettings settings; if (!ParseSettings(source, parameter, settings)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } if ((settings.Backlog > 0) && (settings.Lines > settings.Backlog)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, "You can't set lines higher than backlog.")); - return MODEACTION_DENY; + return false; } LocalUser* localsource = IS_LOCAL(source); if ((localsource) && (!ValidateSettings(localsource, channel, parameter, settings))) - return MODEACTION_DENY; + return false; ext.Set(channel, settings); - return MODEACTION_ALLOW; + return true; } bool MatchLine(Membership* memb, ChannelSettings* rs, std::string message) diff --git a/src/modules/m_services.cpp b/src/modules/m_services.cpp index 6e557334c..ece510f7d 100644 --- a/src/modules/m_services.cpp +++ b/src/modules/m_services.cpp @@ -31,12 +31,12 @@ public: DisableAutoRegister(); } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { if (IS_LOCAL(source)) { source->WriteNumeric(ERR_NOPRIVILEGES, "Only a server may modify the +r channel mode"); - return MODEACTION_DENY; + return false; } return SimpleChannelMode::OnModeChange(source, dest, channel, change); @@ -55,12 +55,12 @@ public: DisableAutoRegister(); } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { if (IS_LOCAL(source)) { source->WriteNumeric(ERR_NOPRIVILEGES, "Only a server may modify the +r user mode"); - return MODEACTION_DENY; + return false; } return SimpleUserMode::OnModeChange(source, dest, channel, change); diff --git a/src/modules/m_servprotect.cpp b/src/modules/m_servprotect.cpp index 05e9de178..c9f25c45b 100644 --- a/src/modules/m_servprotect.cpp +++ b/src/modules/m_servprotect.cpp @@ -40,9 +40,9 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { - /* Because this returns MODEACTION_DENY all the time, there is only ONE + /* Because this returns false all the time, there is only ONE * way to add this mode and that is at client introduction in the UID command, * as this calls OnModeChange for each mode but disregards the return values. * The mode cannot be manually added or removed, not even by a server or by a remote @@ -50,7 +50,7 @@ public: * I'm sure if someone really wants to do that they can make a copy of this module * that does the job. It won't be me though! */ - return MODEACTION_DENY; + return false; } }; diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp index 2610aa084..d0a184cf3 100644 --- a/src/modules/m_sslmodes.cpp +++ b/src/modules/m_sslmodes.cpp @@ -76,7 +76,7 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { if (change.adding) { @@ -87,7 +87,7 @@ public: if (!API) { source->WriteNumeric(ERR_ALLMUSTSSL, channel->name, "Unable to determine whether all members of the channel are connected via TLS"); - return MODEACTION_DENY; + return false; } size_t nonssl = 0; @@ -102,15 +102,15 @@ public: { source->WriteNumeric(ERR_ALLMUSTSSL, channel->name, InspIRCd::Format("All members of the channel must be connected via TLS (%zu/%zu are non-TLS)", nonssl, channel->GetUsers().size())); - return MODEACTION_DENY; + return false; } } channel->SetMode(this, true); - return MODEACTION_ALLOW; + return true; } else { - return MODEACTION_DENY; + return false; } } else @@ -118,10 +118,10 @@ public: if (channel->IsModeSet(this)) { channel->SetMode(this, false); - return MODEACTION_ALLOW; + return true; } - return MODEACTION_DENY; + return false; } } }; @@ -141,16 +141,16 @@ public: { } - ModeAction OnModeChange(User* user, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* user, User* dest, Channel* channel, Modes::Change& change) override { if (change.adding == dest->IsModeSet(this)) - return MODEACTION_DENY; + return false; if (change.adding && IS_LOCAL(user) && (!API || !API->GetCertificate(user))) - return MODEACTION_DENY; + return false; dest->SetMode(this, change.adding); - return MODEACTION_ALLOW; + return true; } }; -- cgit v1.3.1-10-gc9f91