diff options
| author | 2024-07-23 23:54:29 +0100 | |
|---|---|---|
| committer | 2024-07-24 00:31:34 +0100 | |
| commit | a4bee21ab53cebc9953849412611add66a7330e7 (patch) | |
| tree | 9e3477fda5ea70bd690df737cd54c7076879d716 | |
| parent | Add SendMetadata methods to Server. (diff) | |
Update all usages of ProtocolServer to use Server.
| -rw-r--r-- | include/modules/server.h | 6 | ||||
| -rw-r--r-- | include/protocol.h | 12 | ||||
| -rw-r--r-- | src/modules/m_filter.cpp | 4 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/fjoin.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/ijoin.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 29 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/protocolinterface.cpp | 5 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/protocolinterface.h | 13 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/treesocket.h | 9 |
9 files changed, 19 insertions, 63 deletions
diff --git a/include/modules/server.h b/include/modules/server.h index 20ea8b0be..59ddc55d2 100644 --- a/include/modules/server.h +++ b/include/modules/server.h @@ -123,17 +123,17 @@ public: * @param user The user being synchronized. * @param server The target of the burst. */ - virtual void OnSyncUser(User* user, ProtocolServer& server) { } + virtual void OnSyncUser(User* user, Server& server) { } /** Allows modules to synchronize channel metadata during a netburst. This will * be called for every channel visible on your side of the burst. * @param chan The channel being synchronized. * @param server The target of the burst. */ - virtual void OnSyncChannel(Channel* chan, ProtocolServer& server) { } + virtual void OnSyncChannel(Channel* chan, Server& server) { } /** Allows modules to synchronize network metadata during a netburst. * @param server The target of the burst. */ - virtual void OnSyncNetwork(ProtocolServer& server) { } + virtual void OnSyncNetwork(Server& server) { } }; diff --git a/include/protocol.h b/include/protocol.h index 882c1d3ce..305151330 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -27,19 +27,13 @@ class User; -class ProtocolServer -{ -public: - /** Send metadata related to this server to the target server - * @param key The 'key' of the data - * @param data The string representation of the data - */ - virtual void SendMetadata(const std::string& key, const std::string& data) = 0; -}; +[[deprecated("ProtocolServer has been merged with Server")]] +typedef ::Server ProtocolServer; class CoreExport ProtocolInterface { public: + [[deprecated("ProtocolInterface::Server has been merged with Server")]] typedef ProtocolServer Server; class ServerInfo final diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index bd55fd3c8..d882cea7f 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -236,7 +236,7 @@ public: void GetLinkData(LinkData& data, std::string& compatdata) override; static std::string EncodeFilter(const FilterResult& filter); FilterResult DecodeFilter(const std::string& data); - void OnSyncNetwork(ProtocolInterface::Server& server) override; + void OnSyncNetwork(Server& server) override; void OnDecodeMetadata(Extensible* target, const std::string& extname, const std::string& extdata) override; ModResult OnStats(Stats::Context& stats) override; ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) override; @@ -738,7 +738,7 @@ FilterResult ModuleFilter::DecodeFilter(const std::string& data) return res; } -void ModuleFilter::OnSyncNetwork(ProtocolInterface::Server& server) +void ModuleFilter::OnSyncNetwork(Server& server) { for (const auto& filter : filters) { diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index f7593995c..874a53ae2 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -147,7 +147,7 @@ CmdResult CommandFJoin::Handle(User* srcuser, Params& params) if (!sourceserver->IsBursting()) { ServerInstance->Logs.Debug(MODNAME, "Server {} recreated channel {} with higher TS, resyncing", sourceserver->GetName(), chan->name); - sourceserver->GetSocket()->SyncChannel(chan); + sourceserver->GetSocket()->SyncChannel(chan, sourceserver); } apply_other_sides_modes = false; } diff --git a/src/modules/m_spanningtree/ijoin.cpp b/src/modules/m_spanningtree/ijoin.cpp index 9a810ca22..810273e03 100644 --- a/src/modules/m_spanningtree/ijoin.cpp +++ b/src/modules/m_spanningtree/ijoin.cpp @@ -71,6 +71,6 @@ CmdResult CommandResync::HandleServer(TreeServer* server, CommandBase::Params& p throw ProtocolException("RESYNC from a server that is not directly connected"); // Send all known information about the channel - server->GetSocket()->SyncChannel(chan); + server->GetSocket()->SyncChannel(chan, server); return CmdResult::SUCCESS; } diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 798987975..d862b48f7 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -84,15 +84,6 @@ public: } }; -struct TreeSocket::BurstState final -{ - 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 @@ -109,17 +100,16 @@ void TreeSocket::DoBurst(TreeServer* s) // Introduce all servers behind us this->SendServers(Utils->TreeRoot, s); - BurstState bs(this); // Introduce all users - this->SendUsers(bs); + this->SendUsers(s); // Sync all channels for (const auto& [_, chan] : ServerInstance->Channels.GetChans()) - SyncChannel(chan, bs); + SyncChannel(chan, s); // Send all xlines this->SendXLines(); - Utils->Creator->synceventprov.Call(&ServerProtocol::SyncEventListener::OnSyncNetwork, bs.server); + Utils->Creator->synceventprov.Call(&ServerProtocol::SyncEventListener::OnSyncNetwork, *s); this->WriteLine(CmdBuilder("ENDBURST")); ServerInstance->SNO.WriteToSnoMask('l', "Finished bursting to \002"+ s->GetName()+"\002."); } @@ -236,7 +226,7 @@ void TreeSocket::SendLegacyListModes(Channel* chan) } /** Send channel users, topic, modes and global metadata */ -void TreeSocket::SyncChannel(Channel* chan, BurstState& bs) +void TreeSocket::SyncChannel(Channel* chan, TreeServer* s) { SendFJoins(chan); @@ -265,17 +255,12 @@ void TreeSocket::SyncChannel(Channel* chan, BurstState& bs) } } - Utils->Creator->synceventprov.Call(&ServerProtocol::SyncEventListener::OnSyncChannel, chan, bs.server); + Utils->Creator->synceventprov.Call(&ServerProtocol::SyncEventListener::OnSyncChannel, chan, *s); } -void TreeSocket::SyncChannel(Channel* chan) -{ - BurstState bs(this); - SyncChannel(chan, bs); -} /** Send all users and their state, including oper and away status and global metadata */ -void TreeSocket::SendUsers(BurstState& bs) +void TreeSocket::SendUsers(TreeServer* s) { for (const auto& [_, user] : ServerInstance->Users.GetUsers()) { @@ -300,6 +285,6 @@ void TreeSocket::SendUsers(BurstState& bs) this->WriteLine(CommandMetadata::Builder(user, item->name, value)); } - Utils->Creator->synceventprov.Call(&ServerProtocol::SyncEventListener::OnSyncUser, user, bs.server); + Utils->Creator->synceventprov.Call(&ServerProtocol::SyncEventListener::OnSyncUser, user, *s); } } diff --git a/src/modules/m_spanningtree/protocolinterface.cpp b/src/modules/m_spanningtree/protocolinterface.cpp index 533551c0b..aaeeb5c60 100644 --- a/src/modules/m_spanningtree/protocolinterface.cpp +++ b/src/modules/m_spanningtree/protocolinterface.cpp @@ -96,11 +96,6 @@ 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::SendSNONotice(char snomask, const std::string& text) { CmdBuilder("SNONOTICE").push(snomask).push_last(text).Broadcast(); diff --git a/src/modules/m_spanningtree/protocolinterface.h b/src/modules/m_spanningtree/protocolinterface.h index 3cf6917f2..daf0efbfb 100644 --- a/src/modules/m_spanningtree/protocolinterface.h +++ b/src/modules/m_spanningtree/protocolinterface.h @@ -27,19 +27,6 @@ class SpanningTreeProtocolInterface final : public ProtocolInterface { public: - class Server final - : public ProtocolInterface::Server - { - TreeSocket* const sock; - - public: - Server(TreeSocket* s) - : sock(s) - { - } - void SendMetadata(const std::string& key, const std::string& data) override; - }; - bool SendEncapsulatedData(const std::string& targetmask, const std::string& cmd, const CommandBase::Params& params, const User* source) override; void BroadcastEncap(const std::string& cmd, const CommandBase::Params& params, const User* source, const User* omit) override; void SendMetadata(const Extensible* ext, const std::string& key, const std::string& data) override; diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h index 9a57e81eb..f195ddb6a 100644 --- a/src/modules/m_spanningtree/treesocket.h +++ b/src/modules/m_spanningtree/treesocket.h @@ -130,8 +130,6 @@ struct CapabData final class TreeSocket final : public BufferedSocket { - struct BurstState; - std::string linkID; /* Description for this link */ ServerState LinkState; /* Link state */ std::unique_ptr<CapabData> capab; /* Link setup data (held until burst is sent) */ @@ -148,11 +146,8 @@ class TreeSocket final void SendListModes(Channel* chan); void SendLegacyListModes(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); + void SendUsers(TreeServer* s); /** Send all additional info about the given server to this server */ void SendServerInfo(TreeServer* from); @@ -308,7 +303,7 @@ public: void SendXLines(); /** Send all known information about a channel */ - void SyncChannel(Channel* chan); + void SyncChannel(Channel* chan, TreeServer* s); /** 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 |
