diff options
| author | 2026-03-11 21:54:40 +0000 | |
|---|---|---|
| committer | 2026-03-12 00:18:06 +0000 | |
| commit | fcb3090055429a108b9837dbd4ba505d9c291129 (patch) | |
| tree | 5c55fd77d3b24adeda54e250d91b2a44badc9c5d /modules/spanningtree/postcommand.cpp | |
| parent | Mark all acting extbans as MATCH_REQUIRE_CHANNEL. (diff) | |
Rework sending server protocol messages.
- Replace CmdBuilder with MessageBuilder. This has a less footgun
API. All message building has to go through this now so we can
implement other message formats in the future.
- Replace the message parsing in WriteLine with an analogue to
PreProcessOldProtocolMessage. This should be much faster.
- Move parameter translation from the core to spanningtree.
- Change EncodeParameter to return the value instead of updating
in place.
- Replace the OnBuild*Message events with one OnServerMessage that
can now access all parts of the message and change them.
Diffstat (limited to 'modules/spanningtree/postcommand.cpp')
| -rw-r--r-- | modules/spanningtree/postcommand.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/modules/spanningtree/postcommand.cpp b/modules/spanningtree/postcommand.cpp index 1f9e20a55..dbcdf15ae 100644 --- a/modules/spanningtree/postcommand.cpp +++ b/modules/spanningtree/postcommand.cpp @@ -24,8 +24,8 @@ #include "main.h" #include "utils.h" +#include "translate.h" #include "treeserver.h" -#include "commandbuilder.h" void ModuleSpanningTree::OnPostCommand(Command* command, const CommandBase::Params& parameters, LocalUser* user, CmdResult result, bool loop) { @@ -41,14 +41,13 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm const std::string& command = thiscmd->service_name; const bool encap = ((routing.type == RouteType::OPTIONAL_BROADCAST) || (routing.type == RouteType::OPTIONAL_UNICAST)); - CmdBuilder params(user, encap ? "ENCAP" : command.c_str()); - params.push_tags(parameters.GetTags()); + MessageBuilder msg(user, encap ? "ENCAP" : command); + msg.PushTags(parameters.GetTags()); const TreeServer* sdest = nullptr; if (routing.type == RouteType::OPTIONAL_BROADCAST) { - params.push('*'); - params.push(command); + msg.Push('*', command); } else if (routing.type == RouteType::UNICAST || routing.type == RouteType::OPTIONAL_UNICAST) { @@ -66,10 +65,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm } if (encap) - { - params.push(sdest->GetId()); - params.push(command); - } + msg.Push(sdest->GetId(), command); } else { @@ -82,9 +78,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm } } - std::string output_text = CommandParser::TranslateUIDs(thiscmd->translation, parameters, true, thiscmd); - - params.push(output_text); + msg.PushParams(Translate::ParamsToNetwork(thiscmd->translation, parameters, thiscmd)); if (routing.type == RouteType::MESSAGE) { @@ -109,7 +103,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm } else if (dest[0] == '$') { - params.Forward(origin); + msg.Broadcast(origin); } else { @@ -119,17 +113,19 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm return; TreeServer* tsd = TreeServer::Get(d)->GetRoute(); if (tsd == origin) + { // huh? no routing stuff around in a circle, please. return; - params.Unicast(d); + } + msg.Unicast(d); } } else if (routing.type == RouteType::BROADCAST || routing.type == RouteType::OPTIONAL_BROADCAST) { - params.Forward(origin); + msg.Broadcast(origin); } else if (routing.type == RouteType::UNICAST || routing.type == RouteType::OPTIONAL_UNICAST) { - params.Unicast(sdest->ServerUser); + msg.Unicast(sdest->ServerUser); } } |
