]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/treesocket1.cpp
Support port binding here
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / treesocket1.cpp
index 31564b017d8488c389532d4e8f3faed404e324ab..1e25a2fff65a24151f5cf59aebd9cf2d5d3be1a8 100644 (file)
@@ -35,8 +35,8 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, InspIRCd* SI, std::string ho
                InspSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send();
 }
 
-TreeSocket::TreeSocket(SpanningTreeUtilities* Util, InspIRCd* SI, std::string host, int port, bool listening, unsigned long maxtime, std::string ServerName, Module* HookMod)
-       : InspSocket(SI, host, port, listening, maxtime), Utils(Util), Hook(HookMod)
+TreeSocket::TreeSocket(SpanningTreeUtilities* Util, InspIRCd* SI, std::string host, int port, bool listening, unsigned long maxtime, const std::string &ServerName, const std::string &bindto, Module* HookMod)
+       : InspSocket(SI, host, port, listening, maxtime, bindto), Utils(Util), Hook(HookMod)
 {
        myhost = ServerName;
        this->LinkState = CONNECTING;
@@ -981,12 +981,6 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
                        who = this->Instance->FindNick(usr);
                        if (who)
                        {
-                               /* Did they get any modes? How many times? */
-                               strlcat(modestring, nm, MAXBUF);
-                               for (int k = 0; k < ntimes; k++)
-                                       mode_users[modectr++] = strdup(usr);
-                               /* Free temporary buffer used for mode sequence */
-                               delete[] nm;
                                /* Check that the user's 'direction' is correct
                                 * based on the server sending the FJOIN. We must
                                 * check each nickname in turn, because the origin of
@@ -997,8 +991,23 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
                                if ((!route_back_again) || (route_back_again->GetSocket() != this))
                                {
                                        /* Oh dear oh dear. */
+                                       delete[] nm;
                                        continue;
                                }
+
+                               /* NOTE: Moved this below the fake direction check, so that modes
+                                * arent put into the mode list for users that were collided, and
+                                * may reconnect from the other side or our side before the split
+                                * is completed!
+                                */
+
+                               /* Did they get any modes? How many times? */
+                               strlcat(modestring, nm, MAXBUF);
+                               for (int k = 0; k < ntimes; k++)
+                                       mode_users[modectr++] = strdup(usr);
+                               /* Free temporary buffer used for mode sequence */
+                               delete[] nm;
+
                                /* Finally, we can actually place the user into the channel.
                                 * We're sure its right. Final answer, phone a friend.
                                 */
@@ -1054,7 +1063,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
                                 * in case somehow we're desynched, so that other users which might be able to see
                                 * the nickname get their fair chance to process it.
                                 */
-                               Instance->Log(SPARSE,"Warning! Invalid user in FJOIN to channel %s IGNORED", channel.c_str());
+                               Instance->Log(SPARSE,"Warning! Invalid user %s in FJOIN to channel %s IGNORED", usr, channel.c_str());
                                continue;
                        }
                }