]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_spanningtree Send, parse and translate IJOINs with membership ids
authorAttila Molnar <attilamolnar@hush.com>
Wed, 11 Jun 2014 12:30:17 +0000 (14:30 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Wed, 11 Jun 2014 12:30:17 +0000 (14:30 +0200)
src/modules/m_spanningtree/commands.h
src/modules/m_spanningtree/compat.cpp
src/modules/m_spanningtree/ijoin.cpp
src/modules/m_spanningtree/main.cpp

index d2d138ab26b6ce99b308d63e062644714daf79d0..110b3d93d9afd426122872288c0e2efeb88c7f6b 100644 (file)
@@ -181,7 +181,7 @@ class CommandFName : public UserOnlyServerCommand<CommandFName>
 class CommandIJoin : public UserOnlyServerCommand<CommandIJoin>
 {
  public:
-       CommandIJoin(Module* Creator) : UserOnlyServerCommand<CommandIJoin>(Creator, "IJOIN", 1) { }
+       CommandIJoin(Module* Creator) : UserOnlyServerCommand<CommandIJoin>(Creator, "IJOIN", 2) { }
        CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
 };
 
index ca9fbfa6aad69f61d891136c1fd9cb6c396c7ba1..dc4315cb7506311c9db487958f997b099211ffc5 100644 (file)
@@ -47,11 +47,17 @@ void TreeSocket::WriteLine(const std::string& original_line)
                                if (command == "IJOIN")
                                {
                                        // Convert
-                                       // :<uid> IJOIN <chan> [<ts> [<flags>]]
+                                       // :<uid> IJOIN <chan> <membid> [<ts> [<flags>]]
                                        // to
                                        // :<sid> FJOIN <chan> <ts> + [<flags>],<uuid>
                                        std::string::size_type c = line.find(' ', b + 1);
                                        if (c == std::string::npos)
+                                               return;
+
+                                       std::string::size_type d = line.find(' ', c + 1);
+                                       // Erase membership id first
+                                       line.erase(c, d-c);
+                                       if (d == std::string::npos)
                                        {
                                                // No TS or modes in the command
                                                // :22DAAAAAB IJOIN #chan
@@ -66,7 +72,7 @@ void TreeSocket::WriteLine(const std::string& original_line)
                                        }
                                        else
                                        {
-                                               std::string::size_type d = line.find(' ', c + 1);
+                                               d = line.find(' ', c + 1);
                                                if (d == std::string::npos)
                                                {
                                                        // TS present, no modes
index 34bd44a9b2cfd885f13569673972b6d8cbd90655..78e05db93fbb841090e5c18257bcdf9ecd42a2f7 100644 (file)
@@ -38,17 +38,22 @@ CmdResult CommandIJoin::HandleRemote(RemoteUser* user, std::vector<std::string>&
        }
 
        bool apply_modes;
-       if (params.size() > 1)
+       if (params.size() > 2)
        {
-               time_t RemoteTS = ServerCommand::ExtractTS(params[1]);
+               time_t RemoteTS = ServerCommand::ExtractTS(params[2]);
                if (RemoteTS < chan->age)
                        throw ProtocolException("Attempted to lower TS via IJOIN. LocalTS=" + ConvToStr(chan->age));
-               apply_modes = ((params.size() > 2) && (RemoteTS == chan->age));
+               apply_modes = ((params.size() > 3) && (RemoteTS == chan->age));
        }
        else
                apply_modes = false;
 
-       chan->ForceJoin(user, apply_modes ? &params[2] : NULL);
+       // Join the user and set the membership id to what they sent
+       Membership* memb = chan->ForceJoin(user, apply_modes ? &params[3] : NULL);
+       if (!memb)
+               return CMD_FAILURE;
+
+       memb->id = Membership::IdFromString(params[1]);
        return CMD_SUCCESS;
 }
 
index 6fa4948096e96835044f6bc9bb7d48b8ed8ac1e2..6a21ca4f6b9ceef9ee68db8d8afae8f7bf28ba42 100644 (file)
@@ -527,6 +527,7 @@ void ModuleSpanningTree::OnUserJoin(Membership* memb, bool sync, bool created_by
        {
                CmdBuilder params(memb->user, "IJOIN");
                params.push_back(memb->chan->name);
+               params.push_int(memb->id);
                if (!memb->modes.empty())
                {
                        params.push_back(ConvToStr(memb->chan->age));