aboutsummaryrefslogtreecommitdiffstats
path: root/modules/spanningtree/server.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2026-03-11 21:54:40 +0000
committerGravatar Sadie Powell2026-03-12 00:18:06 +0000
commitfcb3090055429a108b9837dbd4ba505d9c291129 (patch)
tree5c55fd77d3b24adeda54e250d91b2a44badc9c5d /modules/spanningtree/server.cpp
parentMark 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/server.cpp')
-rw-r--r--modules/spanningtree/server.cpp24
1 files changed, 12 insertions, 12 deletions
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());
}