From fcb3090055429a108b9837dbd4ba505d9c291129 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 11 Mar 2026 21:54:40 +0000 Subject: 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. --- modules/spanningtree/server.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'modules/spanningtree/server.cpp') diff --git a/modules/spanningtree/server.cpp b/modules/spanningtree/server.cpp index 88a2f4267..c0ba87fa7 100644 --- a/modules/spanningtree/server.cpp +++ b/modules/spanningtree/server.cpp @@ -240,12 +240,12 @@ bool TreeSocket::Inbound_Server(CommandBase::Params& params) // Send our details: Our server name and description and hopcount of 0, // along with the sendpass from this block. - this->WriteLine(FMT::format("SERVER {} {} {} :{}", - ServerInstance->Config->ServerName, - TreeSocket::MakePass(x->SendPass, this->GetTheirChallenge()), - ServerInstance->Config->ServerId, - ServerInstance->Config->ServerDesc - )); + MessageBuilder("SERVER", true) + .Push(ServerInstance->Config->ServerName, + TreeSocket::MakePass(x->SendPass, this->GetTheirChallenge()), + ServerInstance->Config->ServerId, + ServerInstance->Config->ServerDesc) + .Unicast(this); // move to the next state, we are now waiting for THEM. this->LinkState = WAIT_AUTH_2; @@ -256,12 +256,12 @@ bool TreeSocket::Inbound_Server(CommandBase::Params& params) } CommandServer::Builder::Builder(TreeServer* server) - : CmdBuilder(server->GetTreeParent(), "SERVER") + : MessageBuilder(server->GetTreeParent(), "SERVER") { - push(server->GetName()); - push(server->GetId()); + Push(server->GetName()); + Push(server->GetId()); if (server->IsBursting()) - push_property("burst", ConvToStr(server->StartBurst)); - push_property("hidden", ConvToStr(server->Hidden)); - push_last(server->GetDesc()); + PushProperty("burst", server->StartBurst); + PushProperty("hidden", server->Hidden); + Push(server->GetDesc()); } -- cgit v1.3.1-10-gc9f91