From eef45dbfb90f951f3048038aea3ff68b5c157f6d Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Fri, 2 Sep 2016 19:22:50 +0200 Subject: m_spanningtree Refuse topic changes that would result in desync This is a workaround until the protocol is updated --- src/modules/m_spanningtree/main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/modules/m_spanningtree/main.cpp') diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 56cc78cd2..6bf9e8044 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -365,6 +365,18 @@ void ModuleSpanningTree::OnUserInvite(User* source, User* dest, Channel* channel } } +ModResult ModuleSpanningTree::OnPreTopicChange(User* user, Channel* chan, const std::string& topic) +{ + // XXX: Deny topic changes if the current topic set time is the current time or is in the future because + // other servers will drop our FTOPIC. This restriction will be removed when the protocol is updated. + if ((chan->topicset >= ServerInstance->Time()) && (Utils->serverlist.size() > 1)) + { + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, chan->name, "Retry topic change later"); + return MOD_RES_DENY; + } + return MOD_RES_PASSTHRU; +} + void ModuleSpanningTree::OnPostTopicChange(User* user, Channel* chan, const std::string &topic) { // Drop remote events on the floor. @@ -762,6 +774,7 @@ Version ModuleSpanningTree::GetVersion() void ModuleSpanningTree::Prioritize() { ServerInstance->Modules->SetPriority(this, PRIORITY_LAST); + ServerInstance->Modules.SetPriority(this, I_OnPreTopicChange, PRIORITY_FIRST); } MODULE_INIT(ModuleSpanningTree) -- cgit v1.3.1-10-gc9f91