]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_spanningtree Send MODE/FMODE from the OnMode hook
authorAttila Molnar <attilamolnar@hush.com>
Wed, 3 Sep 2014 12:26:40 +0000 (14:26 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Wed, 3 Sep 2014 12:26:40 +0000 (14:26 +0200)
If the MODE_LOCALONLY flag is set the mode change is not propagated

include/mode.h
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/main.h
src/modules/m_spanningtree/protocolinterface.cpp

index 981c29a277f89bf90614127e5bdff7922a4f71d5..5bf8dc2046329aa0ea01c99972b592785adc6f2d 100644 (file)
@@ -608,8 +608,8 @@ class CoreExport ModeParser : public fakederef<ModeParser>
                 */
                MODE_MERGE = 1,
 
                 */
                MODE_MERGE = 1,
 
-               /** If this flag is set then the mode change won't be handed over to
-                * the linking module to be sent to other servers, but will be processed
+               /** If this flag is set then the linking module will ignore the mode change
+                * and not send it to other servers. The mode change will be processed
                 * locally and sent to local user(s) as usual.
                 */
                MODE_LOCALONLY = 2
                 * locally and sent to local user(s) as usual.
                 */
                MODE_LOCALONLY = 2
index 74bbf0b8a75b914bf0cae0cd97bc3736812af033..c21064683057dff28d8c9f3767616e034d55b37d 100644 (file)
@@ -33,6 +33,7 @@
 #include "link.h"
 #include "treesocket.h"
 #include "commands.h"
 #include "link.h"
 #include "treesocket.h"
 #include "commands.h"
+#include "translate.h"
 
 ModuleSpanningTree::ModuleSpanningTree()
        : rconnect(this), rsquit(this), map(this)
 
 ModuleSpanningTree::ModuleSpanningTree()
        : rconnect(this), rsquit(this), map(this)
@@ -751,6 +752,33 @@ ModResult ModuleSpanningTree::OnSetAway(User* user, const std::string &awaymsg)
        return MOD_RES_PASSTHRU;
 }
 
        return MOD_RES_PASSTHRU;
 }
 
+void ModuleSpanningTree::OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags, const std::string& output_mode)
+{
+       if (processflags & ModeParser::MODE_LOCALONLY)
+               return;
+
+       if (u)
+       {
+               if (u->registered != REG_ALL)
+                       return;
+
+               CmdBuilder params(source, "MODE");
+               params.push(u->uuid);
+               params.push(output_mode);
+               params.push_raw(Translate::ModeChangeListToParams(modes.getlist()));
+               params.Broadcast();
+       }
+       else
+       {
+               CmdBuilder params(source, "FMODE");
+               params.push(c->name);
+               params.push_int(c->age);
+               params.push(output_mode);
+               params.push_raw(Translate::ModeChangeListToParams(modes.getlist()));
+               params.Broadcast();
+       }
+}
+
 CullResult ModuleSpanningTree::cull()
 {
        if (Utils)
 CullResult ModuleSpanningTree::cull()
 {
        if (Utils)
index 09a42ff0ddb7253d18c53f702a68ccbf74588ad0..c81eb2d0bc023a9a97411c671b769ea78ee376c4 100644 (file)
@@ -168,6 +168,7 @@ class ModuleSpanningTree : public Module
        void OnLoadModule(Module* mod) CXX11_OVERRIDE;
        void OnUnloadModule(Module* mod) CXX11_OVERRIDE;
        ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE;
        void OnLoadModule(Module* mod) CXX11_OVERRIDE;
        void OnUnloadModule(Module* mod) CXX11_OVERRIDE;
        ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE;
+       void OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags, const std::string& output_mode) CXX11_OVERRIDE;
        CullResult cull();
        ~ModuleSpanningTree();
        Version GetVersion() CXX11_OVERRIDE;
        CullResult cull();
        ~ModuleSpanningTree();
        Version GetVersion() CXX11_OVERRIDE;
index 192f7cff2ca2e5abae2ddee5d384b1a2e7038ff3..3ad75a430b48ab0f9d18277696be590be4bb8fcc 100644 (file)
@@ -109,24 +109,6 @@ void SpanningTreeProtocolInterface::SendTopic(Channel* channel, std::string &top
 
 void SpanningTreeProtocolInterface::SendMode(User* source, User* u, Channel* c, const std::vector<std::string>& modedata, const std::vector<TranslateType>& translate)
 {
 
 void SpanningTreeProtocolInterface::SendMode(User* source, User* u, Channel* c, const std::vector<std::string>& modedata, const std::vector<TranslateType>& translate)
 {
-       if (u)
-       {
-               if (u->registered != REG_ALL)
-                       return;
-
-               CmdBuilder params(source, "MODE");
-               params.push_back(u->uuid);
-               params.insert(modedata);
-               params.Broadcast();
-       }
-       else
-       {
-               CmdBuilder params(source, "FMODE");
-               params.push_back(c->name);
-               params.push_back(ConvToStr(c->age));
-               params.push_back(CommandParser::TranslateUIDs(translate, modedata));
-               params.Broadcast();
-       }
 }
 
 void SpanningTreeProtocolInterface::SendSNONotice(char snomask, const std::string &text)
 }
 
 void SpanningTreeProtocolInterface::SendSNONotice(char snomask, const std::string &text)