diff options
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 13 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 1 | ||||
-rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 34 | ||||
-rw-r--r-- | src/modules/m_spanningtree/protocolinterface.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_spanningtree/protocolinterface.h | 9 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket.h | 11 |
6 files changed, 47 insertions, 26 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index f92c09b88..b3cc78118 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -718,19 +718,6 @@ ModResult ModuleSpanningTree::OnSetAway(User* user, const std::string &awaymsg) return MOD_RES_PASSTHRU; } -void ModuleSpanningTree::ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata) -{ - TreeSocket* s = static_cast<TreeSocket*>(opaque); - User* u = dynamic_cast<User*>(target); - Channel* c = dynamic_cast<Channel*>(target); - if (u) - s->WriteLine(":"+ServerInstance->Config->GetSID()+" METADATA "+u->uuid+" "+extname+" :"+extdata); - else if (c) - s->WriteLine(":"+ServerInstance->Config->GetSID()+" METADATA "+c->name+" "+ConvToStr(c->age)+" "+extname+" :"+extdata); - else if (!target) - s->WriteLine(":"+ServerInstance->Config->GetSID()+" METADATA * "+extname+" :"+extdata); -} - CullResult ModuleSpanningTree::cull() { if (Utils) diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 737b7d576..c275207bf 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -158,7 +158,6 @@ class ModuleSpanningTree : public Module void OnDelLine(User *u, XLine *x) CXX11_OVERRIDE; ModResult OnStats(char statschar, User* user, string_list &results) CXX11_OVERRIDE; ModResult OnSetAway(User* user, const std::string &awaymsg) CXX11_OVERRIDE; - void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata); void OnLoadModule(Module* mod) CXX11_OVERRIDE; void OnUnloadModule(Module* mod) CXX11_OVERRIDE; ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE; diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 9ca5b04d4..0464590e8 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -27,6 +27,7 @@ #include "treeserver.h" #include "main.h" #include "commands.h" +#include "protocolinterface.h" /** * Creates FMODE messages, used only when syncing channels @@ -89,6 +90,12 @@ class FModeBuilder : public CmdBuilder } }; +struct TreeSocket::BurstState +{ + SpanningTreeProtocolInterface::Server server; + BurstState(TreeSocket* sock) : server(sock) { } +}; + /** This function is called when we want to send a netburst to a local * server. There is a set order we must do this, because for example * users require their servers to exist, and channels require their @@ -106,14 +113,16 @@ void TreeSocket::DoBurst(TreeServer* s) this->WriteLine(":" + ServerInstance->Config->GetSID() + " VERSION :"+ServerInstance->GetVersionString()); /* Send server tree */ this->SendServers(Utils->TreeRoot, s); + + BurstState bs(this); /* Send users and their oper status */ - this->SendUsers(); + this->SendUsers(bs); for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); ++i) - SyncChannel(i->second); + SyncChannel(i->second, bs); this->SendXLines(); - FOREACH_MOD(OnSyncNetwork, (Utils->Creator,(void*)this)); + FOREACH_MOD(OnSyncNetwork, (bs.server)); this->WriteLine(":" + ServerInstance->Config->GetSID() + " ENDBURST"); ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \2"+ s->GetName()+"\2."); } @@ -229,7 +238,7 @@ void TreeSocket::SendListModes(Channel* chan) } /** Send channel topic, modes and metadata */ -void TreeSocket::SyncChannel(Channel* chan) +void TreeSocket::SyncChannel(Channel* chan, BurstState& bs) { SendFJoins(chan); @@ -245,15 +254,22 @@ void TreeSocket::SyncChannel(Channel* chan) ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_NETWORK, chan, i->second); if (!value.empty()) - Utils->Creator->ProtoSendMetaData(this, chan, item->name, value); + this->WriteLine(CommandMetadata::Builder(chan, item->name, value)); } - FOREACH_MOD(OnSyncChannel, (chan, Utils->Creator, this)); + FOREACH_MOD(OnSyncChannel, (chan, bs.server)); +} + +void TreeSocket::SyncChannel(Channel* chan) +{ + BurstState bs(this); + SyncChannel(chan, bs); } /** send all users and their oper state/modes */ -void TreeSocket::SendUsers() +void TreeSocket::SendUsers(BurstState& bs) { + ProtocolInterface::Server& piserver = bs.server; for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++) { User* user = u->second; @@ -274,10 +290,10 @@ void TreeSocket::SendUsers() ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_NETWORK, u->second, i->second); if (!value.empty()) - Utils->Creator->ProtoSendMetaData(this, u->second, item->name, value); + this->WriteLine(CommandMetadata::Builder(user, item->name, value)); } - FOREACH_MOD(OnSyncUser, (user, Utils->Creator, this)); + FOREACH_MOD(OnSyncUser, (user, piserver)); } } diff --git a/src/modules/m_spanningtree/protocolinterface.cpp b/src/modules/m_spanningtree/protocolinterface.cpp index cc015ff4a..a6c826c7b 100644 --- a/src/modules/m_spanningtree/protocolinterface.cpp +++ b/src/modules/m_spanningtree/protocolinterface.cpp @@ -71,6 +71,11 @@ void SpanningTreeProtocolInterface::SendMetaData(const std::string& key, const s CommandMetadata::Builder(key, data).Broadcast(); } +void SpanningTreeProtocolInterface::Server::SendMetaData(const std::string& key, const std::string& data) +{ + sock->WriteLine(CommandMetadata::Builder(key, data)); +} + void SpanningTreeProtocolInterface::SendTopic(Channel* channel, std::string &topic) { CommandFTopic::Builder(ServerInstance->FakeClient, channel).Broadcast(); diff --git a/src/modules/m_spanningtree/protocolinterface.h b/src/modules/m_spanningtree/protocolinterface.h index 4ba7a54d4..8b9eeb6a8 100644 --- a/src/modules/m_spanningtree/protocolinterface.h +++ b/src/modules/m_spanningtree/protocolinterface.h @@ -22,6 +22,15 @@ class SpanningTreeProtocolInterface : public ProtocolInterface { public: + class Server : public ProtocolInterface::Server + { + TreeSocket* const sock; + + public: + Server(TreeSocket* s) : sock(s) { } + void SendMetaData(const std::string& key, const std::string& data) CXX11_OVERRIDE; + }; + bool SendEncapsulatedData(const parameterlist &encap); void SendMetaData(User* user, const std::string& key, const std::string& data) CXX11_OVERRIDE; void SendMetaData(Channel* chan, const std::string& key, const std::string& data) CXX11_OVERRIDE; diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h index 8c87c4df6..097f60fbb 100644 --- a/src/modules/m_spanningtree/treesocket.h +++ b/src/modules/m_spanningtree/treesocket.h @@ -89,6 +89,8 @@ struct CapabData */ class TreeSocket : public BufferedSocket { + class BurstState; + std::string linkID; /* Description for this link */ ServerState LinkState; /* Link state */ CapabData* capab; /* Link setup data (held until burst is sent) */ @@ -106,6 +108,12 @@ class TreeSocket : public BufferedSocket */ void SendListModes(Channel* chan); + /** Send all known information about a channel */ + void SyncChannel(Channel* chan, BurstState& bs); + + /** Send all users and their oper state, away state and metadata */ + void SendUsers(BurstState& bs); + public: const time_t age; @@ -224,9 +232,6 @@ class TreeSocket : public BufferedSocket /** Send all known information about a channel */ void SyncChannel(Channel* chan); - /** send all users and their oper state/modes */ - void SendUsers(); - /** This function is called when we want to send a netburst to a local * server. There is a set order we must do this, because for example * users require their servers to exist, and channels require their |