From 722c63ad53dea99829cf010786354e21016aadef Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 4 Jun 2021 01:58:33 +0100 Subject: Broadcast the limits for list modes on server link. This allows services to not overflow the limit. --- src/modules/m_spanningtree/main.cpp | 1 + src/modules/m_spanningtree/netburst.cpp | 1 + src/modules/m_spanningtree/utils.cpp | 22 ++++++++++++++++++++++ src/modules/m_spanningtree/utils.h | 3 +++ 4 files changed, 27 insertions(+) (limited to 'src/modules/m_spanningtree') diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 507897a4e..a2a9173eb 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -511,6 +511,7 @@ void ModuleSpanningTree::OnUserJoin(Membership* memb, bool sync, bool created_by params.add(memb); params.finalize(); params.Broadcast(); + Utils->SendListLimits(memb->chan, NULL); } else { diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index ac68efb96..d8ea30060 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -258,6 +258,7 @@ void TreeSocket::SyncChannel(Channel* chan, BurstState& bs) if (chan->topicset != 0) this->WriteLine(CommandFTopic::Builder(chan)); + Utils->SendListLimits(chan, this); SendListModes(chan); for (Extensible::ExtensibleStore::const_iterator i = chan->GetExtList().begin(); i != chan->GetExtList().end(); i++) diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 809963625..84d96e098 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -25,6 +25,7 @@ #include "inspircd.h" +#include "listmode.h" #include "main.h" #include "utils.h" @@ -374,3 +375,24 @@ void SpanningTreeUtilities::SendChannelMessage(User* source, Channel* target, co Sock->WriteLine(msg); } } + +void SpanningTreeUtilities::SendListLimits(Channel* chan, TreeSocket* sock) +{ + std::stringstream buffer; + const ModeParser::ListModeList& listmodes = ServerInstance->Modes->GetListModes(); + for (ModeParser::ListModeList::const_iterator i = listmodes.begin(); i != listmodes.end(); ++i) + { + ListModeBase* lm = *i; + buffer << lm->GetModeChar() << " " << lm->GetLimit(chan) << " "; + } + + std::string bufferstr = buffer.str(); + if (bufferstr.empty()) + return; // Should never happen. + + bufferstr.erase(bufferstr.end() - 1); + if (sock) + sock->WriteLine(CommandMetadata::Builder(chan, "maxlist", bufferstr)); + else + CommandMetadata::Builder(chan, "maxlist", bufferstr).Broadcast(); +} diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index 26e6e7c22..262c285ef 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -176,6 +176,9 @@ class SpanningTreeUtilities : public classbase /** Sends a PRIVMSG or a NOTICE to a channel obeying an exempt list and an optional prefix */ void SendChannelMessage(User* source, Channel* target, const std::string& text, char status, const ClientProtocol::TagMap& tags, const CUList& exempt_list, const char* message_type, TreeSocket* omit = NULL); + + /** Send the channel list mode limits to either the specified server or all servers if NULL. */ + void SendListLimits(Channel* chan, TreeSocket* sock = NULL); }; inline void SpanningTreeUtilities::DoOneToMany(const CmdBuilder& params) -- cgit v1.2.3