]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/netburst.cpp
m_spanningtree SVSNICK needs 3 parameters
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / netburst.cpp
index 4a894f78a1335af3d17a09e2096137a320c151af..5248ea897e3a33dcc4ba5f4be58ba062cd2d2d68 100644 (file)
@@ -1,16 +1,24 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
  *
- *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
+ *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc>
  *
- * This program is free but copyrighted software; see
- *            the file COPYING for details.
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
  *
- * ---------------------------------------------------
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+
 #include "inspircd.h"
 #include "xline.h"
 
  */
 void TreeSocket::DoBurst(TreeServer* s)
 {
-       std::string name = s->GetName();
-       std::string burst = ":" + ServerInstance->Config->GetSID() + " BURST " +ConvToStr(ServerInstance->Time());
-       std::string endburst = ":" + ServerInstance->Config->GetSID() + " ENDBURST";
+       std::string servername = s->GetName();
        ServerInstance->SNO->WriteToSnoMask('l',"Bursting to \2%s\2 (Authentication: %s%s).",
-               name.c_str(),
+               servername.c_str(),
                capab->auth_fingerprint ? "SSL Fingerprint and " : "",
                capab->auth_challenge ? "challenge-response" : "plaintext password");
        this->CleanNegotiationInfo();
-       this->WriteLine(burst);
+       this->WriteLine(":" + ServerInstance->Config->GetSID() + " BURST " + ConvToStr(ServerInstance->Time()));
        /* send our version string */
-       this->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" VERSION :"+ServerInstance->GetVersionString());
+       this->WriteLine(":" + ServerInstance->Config->GetSID() + " VERSION :"+ServerInstance->GetVersionString());
        /* 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(endburst);
-       ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \2"+name+"\2.");
+       this->WriteLine(":" + ServerInstance->Config->GetSID() + " ENDBURST");
+       ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \2"+ s->GetName()+"\2.");
 }
 
 /** Recursively send the server tree with distances as hops.
@@ -60,17 +66,18 @@ void TreeSocket::DoBurst(TreeServer* s)
  */
 void TreeSocket::SendServers(TreeServer* Current, TreeServer* s, int hops)
 {
-       char command[1024];
+       char command[MAXBUF];
        for (unsigned int q = 0; q < Current->ChildCount(); q++)
        {
                TreeServer* recursive_server = Current->GetChild(q);
                if (recursive_server != s)
                {
-                       snprintf(command,1024,":%s SERVER %s * %d %s :%s",Current->GetName().c_str(),recursive_server->GetName().c_str(),hops,
+                       std::string recursive_servername = recursive_server->GetName();
+                       snprintf(command, MAXBUF, ":%s SERVER %s * %d %s :%s", Current->GetID().c_str(), recursive_servername.c_str(), hops,
                                        recursive_server->GetID().c_str(),
                                        recursive_server->GetDesc().c_str());
                        this->WriteLine(command);
-                       this->WriteLine(":"+recursive_server->GetName()+" VERSION :"+recursive_server->GetVersion());
+                       this->WriteLine(":"+recursive_server->GetID()+" VERSION :"+recursive_server->GetVersion());
                        /* down to next level */
                        this->SendServers(recursive_server, s, hops+1);
                }
@@ -81,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];
@@ -144,7 +151,7 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
                        params.append(" ").append(b->data);
                        linesize += size;
                }
-               if ((params.length() >= ServerInstance->Config->Limits.MaxModes) || (currsize > 350))
+               if ((modes.length() >= ServerInstance->Config->Limits.MaxModes) || (currsize > 350))
                {
                        /* Wrap at MAXMODES */
                        buffer.append(":").append(ServerInstance->Config->GetSID()).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params).append("\r\n");
@@ -161,8 +168,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();
@@ -201,16 +208,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());
@@ -230,7 +237,7 @@ 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;