]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/netburst.cpp
Merge branch 'insp20' into master.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / netburst.cpp
index ffc0a7e1151a87806a6161f39814c3c6e1857126..30a37baee3d1b605ddb939d5f63fba09a3ad86c2 100644 (file)
@@ -27,6 +27,7 @@
 #include "treeserver.h"
 #include "main.h"
 #include "commands.h"
+#include "modules/server.h"
 
 /**
  * Creates FMODE messages, used only when syncing channels
@@ -104,34 +105,41 @@ void TreeSocket::DoBurst(TreeServer* s)
 {
        ServerInstance->SNO->WriteToSnoMask('l',"Bursting to \2%s\2 (Authentication: %s%s).",
                s->GetName().c_str(),
-               capab->auth_fingerprint ? "SSL Fingerprint and " : "",
+               capab->auth_fingerprint ? "SSL certificate fingerprint and " : "",
                capab->auth_challenge ? "challenge-response" : "plaintext password");
        this->CleanNegotiationInfo();
-       this->WriteLine(":" + ServerInstance->Config->GetSID() + " BURST " + ConvToStr(ServerInstance->Time()));
-       /* Send server tree */
+       this->WriteLine(CmdBuilder("BURST").push_int(ServerInstance->Time()));
+       // Introduce all servers behind us
        this->SendServers(Utils->TreeRoot, s);
 
        BurstState bs(this);
-       /* Send users and their oper status */
+       // Introduce all users
        this->SendUsers(bs);
 
+       // Sync all channels
        const chan_hash& chans = ServerInstance->GetChans();
        for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
                SyncChannel(i->second, bs);
 
+       // Send all xlines
        this->SendXLines();
-       FOREACH_MOD(OnSyncNetwork, (bs.server));
-       this->WriteLine(":" + ServerInstance->Config->GetSID() + " ENDBURST");
+       FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnSyncNetwork, (bs.server));
+       this->WriteLine(CmdBuilder("ENDBURST"));
        ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \2"+ s->GetName()+"\2.");
+
+       this->burstsent = true;
 }
 
 void TreeSocket::SendServerInfo(TreeServer* from)
 {
        // Send public version string
-       this->WriteLine(CmdBuilder(from->GetID(), "VERSION").push_last(from->GetVersion()));
+       this->WriteLine(CommandSInfo::Builder(from, "version", from->GetVersion()));
 
        // Send full version string that contains more information and is shown to opers
        this->WriteLine(CommandSInfo::Builder(from, "fullversion", from->GetFullVersion()));
+
+       // Send the raw version string that just contains the base info
+       this->WriteLine(CommandSInfo::Builder(from, "rawversion", from->GetRawVersion()));
 }
 
 /** Recursively send the server tree.
@@ -139,7 +147,6 @@ void TreeSocket::SendServerInfo(TreeServer* from)
  * (and any of ITS servers too) of what servers we know about.
  * If at any point any of these servers already exist on the other
  * end, our connection may be terminated.
- * The hopcount parameter (3rd) is deprecated, and is always 0.
  */
 void TreeSocket::SendServers(TreeServer* Current, TreeServer* s)
 {
@@ -159,17 +166,14 @@ void TreeSocket::SendServers(TreeServer* Current, TreeServer* s)
 }
 
 /** Send one or more FJOINs for a channel of users.
- * If the length of a single line is more than 480-NICKMAX
- * in length, it is split over multiple lines.
- * Send one or more FMODEs for a channel with the
- * channel bans, if there's any.
+ * If the length of a single line is too long, it is split over multiple lines.
  */
 void TreeSocket::SendFJoins(Channel* c)
 {
        CommandFJoin::Builder fjoin(c);
-       const UserMembList *ulist = c->GetUsers();
 
-       for (UserMembCIter i = ulist->begin(); i != ulist->end(); ++i)
+       const Channel::MemberMap& ulist = c->GetUsers();
+       for (Channel::MemberMap::const_iterator i = ulist.begin(); i != ulist.end(); ++i)
        {
                Membership* memb = i->second;
                if (!fjoin.has_room(memb))
@@ -241,7 +245,7 @@ void TreeSocket::SendListModes(Channel* chan)
                this->WriteLine(fmode.finalize());
 }
 
-/** Send channel topic, modes and metadata */
+/** Send channel users, topic, modes and global metadata */
 void TreeSocket::SyncChannel(Channel* chan, BurstState& bs)
 {
        SendFJoins(chan);
@@ -261,7 +265,7 @@ void TreeSocket::SyncChannel(Channel* chan, BurstState& bs)
                        this->WriteLine(CommandMetadata::Builder(chan, item->name, value));
        }
 
-       FOREACH_MOD(OnSyncChannel, (chan, bs.server));
+       FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnSyncChannel, (chan, bs.server));
 }
 
 void TreeSocket::SyncChannel(Channel* chan)
@@ -270,11 +274,9 @@ void TreeSocket::SyncChannel(Channel* chan)
        SyncChannel(chan, bs);
 }
 
-/** send all users and their oper state/modes */
+/** Send all users and their state, including oper and away status and global metadata */
 void TreeSocket::SendUsers(BurstState& bs)
 {
-       ProtocolInterface::Server& piserver = bs.server;
-
        const user_hash& users = ServerInstance->Users->GetUsers();
        for (user_hash::const_iterator u = users.begin(); u != users.end(); ++u)
        {
@@ -299,6 +301,6 @@ void TreeSocket::SendUsers(BurstState& bs)
                                this->WriteLine(CommandMetadata::Builder(user, item->name, value));
                }
 
-               FOREACH_MOD(OnSyncUser, (user, piserver));
+               FOREACH_MOD_CUSTOM(Utils->Creator->GetEventProvider(), ServerEventListener, OnSyncUser, (user, bs.server));
        }
 }