]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/netburst.cpp
Merge pull request #1254 from genius3000/insp20+fixPIstatusmsgs
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / netburst.cpp
index 8319dab8b65d17ebd79ecf4d265e679ca71b239b..3bce90eda30895bcb1be9cf67d013ffcfe607e41 100644 (file)
@@ -34,8 +34,9 @@
  */
 void TreeSocket::DoBurst(TreeServer* s)
 {
+       std::string servername = s->GetName();
        ServerInstance->SNO->WriteToSnoMask('l',"Bursting to \2%s\2 (Authentication: %s%s).",
-               s->GetName().c_str(),
+               servername.c_str(),
                capab->auth_fingerprint ? "SSL Fingerprint and " : "",
                capab->auth_challenge ? "challenge-response" : "plaintext password");
        this->CleanNegotiationInfo();
@@ -45,10 +46,10 @@ void TreeSocket::DoBurst(TreeServer* s)
        /* Send server tree */
        this->SendServers(Utils->TreeRoot,s,1);
        /* Send users and their oper status */
-       this->SendUsers(s);
+       this->SendUsers();
        /* Send everything else (channel modes, xlines etc) */
-       this->SendChannelModes(s);
-       this->SendXLines(s);
+       this->SendChannelModes();
+       this->SendXLines();
        FOREACH_MOD(I_OnSyncNetwork,OnSyncNetwork(Utils->Creator,(void*)this));
        this->WriteLine(":" + ServerInstance->Config->GetSID() + " ENDBURST");
        ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \2"+ s->GetName()+"\2.");
@@ -87,7 +88,7 @@ void TreeSocket::SendServers(TreeServer* Current, TreeServer* s, int hops)
  * If the length of a single line is more than 480-NICKMAX
  * in length, it is split over multiple lines.
  */
-void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
+void TreeSocket::SendFJoins(Channel* c)
 {
        std::string buffer;
        char list[MAXBUF];
@@ -139,25 +140,28 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
                buffer.append(list).append("\r\n");
        }
 
-       int linesize = 1;
+       unsigned int linesize = 1;
        for (BanList::iterator b = c->bans.begin(); b != c->bans.end(); b++)
        {
-               int size = b->data.length() + 2;
-               int currsize = linesize + size;
-               if (currsize <= 350)
-               {
-                       modes.append("b");
-                       params.append(" ").append(b->data);
-                       linesize += size;
-               }
-               if ((modes.length() >= ServerInstance->Config->Limits.MaxModes) || (currsize > 350))
+               unsigned int size = b->data.length() + 2; // "b" and " "
+               unsigned int nextsize = linesize + size;
+
+               if ((modes.length() >= ServerInstance->Config->Limits.MaxModes) || (nextsize > FMODE_MAX_LENGTH))
                {
-                       /* Wrap at MAXMODES */
+                       /* Wrap */
                        buffer.append(":").append(ServerInstance->Config->GetSID()).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params).append("\r\n");
+
                        modes.clear();
                        params.clear();
                        linesize = 1;
                }
+
+               modes.push_back('b');
+
+               params.push_back(' ');
+               params.append(b->data);
+
+               linesize += size;
        }
 
        /* Only send these if there are any */
@@ -167,8 +171,8 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
        this->WriteLine(buffer);
 }
 
-/** Send G, Q, Z and E lines */
-void TreeSocket::SendXLines(TreeServer* Current)
+/** Send all XLines we know about */
+void TreeSocket::SendXLines()
 {
        char data[MAXBUF];
        std::string n = ServerInstance->Config->GetSID();
@@ -207,16 +211,16 @@ void TreeSocket::SendXLines(TreeServer* Current)
        }
 }
 
-/** Send channel modes and topics */
-void TreeSocket::SendChannelModes(TreeServer* Current)
+/** Send channel topic, modes and metadata */
+void TreeSocket::SendChannelModes()
 {
        char data[MAXBUF];
-       std::deque<std::string> list;
        std::string n = ServerInstance->Config->GetSID();
        const char* sn = n.c_str();
+
        for (chan_hash::iterator c = ServerInstance->chanlist->begin(); c != ServerInstance->chanlist->end(); c++)
        {
-               SendFJoins(Current, c->second);
+               SendFJoins(c->second);
                if (!c->second->topic.empty())
                {
                        snprintf(data,MAXBUF,":%s FTOPIC %s %lu %s :%s", sn, c->second->name.c_str(), (unsigned long)c->second->topicset, c->second->setby.c_str(), c->second->topic.c_str());
@@ -236,10 +240,9 @@ void TreeSocket::SendChannelModes(TreeServer* Current)
 }
 
 /** send all users and their oper state/modes */
-void TreeSocket::SendUsers(TreeServer* Current)
+void TreeSocket::SendUsers()
 {
        char data[MAXBUF];
-       std::string dataline;
        for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++)
        {
                if (u->second->registered == REG_ALL)