diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-09-02 19:22:50 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-09-02 19:22:50 +0200 |
commit | eef45dbfb90f951f3048038aea3ff68b5c157f6d (patch) | |
tree | 0c39e4c063ce884502091d85b4be20c3f6284234 /src/modules/m_spanningtree | |
parent | 787ccb22dcc43c707954786f677943e8b746e470 (diff) |
m_spanningtree Refuse topic changes that would result in desync
This is a workaround until the protocol is updated
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 13 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 1 |
2 files changed, 14 insertions, 0 deletions
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) diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index e1c0932b4..46c21b4e9 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -145,6 +145,7 @@ class ModuleSpanningTree : public Module void OnPostCommand(Command*, const std::vector<std::string>& parameters, LocalUser* user, CmdResult result, const std::string& original_line) CXX11_OVERRIDE; void OnUserConnect(LocalUser* source) CXX11_OVERRIDE; void OnUserInvite(User* source, User* dest, Channel* channel, time_t timeout, unsigned int notifyrank, CUList& notifyexcepts) CXX11_OVERRIDE; + ModResult OnPreTopicChange(User* user, Channel* chan, const std::string& topic) CXX11_OVERRIDE; void OnPostTopicChange(User* user, Channel* chan, const std::string &topic) CXX11_OVERRIDE; void OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE; void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE; |