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/protocolinterface.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/protocolinterface.cpp')
| -rw-r--r-- | modules/spanningtree/protocolinterface.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/modules/spanningtree/protocolinterface.cpp b/modules/spanningtree/protocolinterface.cpp index 660148529..d0bf57bc8 100644 --- a/modules/spanningtree/protocolinterface.cpp +++ b/modules/spanningtree/protocolinterface.cpp @@ -53,13 +53,15 @@ bool SpanningTreeProtocolInterface::SendEncapsulatedData(const std::string& targ if (!source) source = ServerInstance->FakeClient; - CmdBuilder encap(source, "ENCAP"); + MessageBuilder msg(source, "ENCAP"); // Are there any wildcards in the target string? if (targetmask.find_first_of("*?") != std::string::npos) { // Yes, send the target string as-is; servers will decide whether or not it matches them - encap.push(targetmask).push(cmd).insert(params).Broadcast(); + msg.Push(targetmask, cmd) + .PushParams(params) + .Broadcast(); } else { @@ -69,7 +71,9 @@ bool SpanningTreeProtocolInterface::SendEncapsulatedData(const std::string& targ return false; // Use the SID of the target in the message instead of the server name - encap.push(server->GetId()).push(cmd).insert(params).Unicast(server->ServerUser); + msg.Push(server->GetId(), cmd) + .PushParams(params) + .Unicast(server->ServerUser); } return true; @@ -83,7 +87,10 @@ void SpanningTreeProtocolInterface::BroadcastEncap(const std::string& cmd, const // If omit is non-NULL we pass the route belonging to the user to Forward(), // otherwise we pass NULL, which is equivalent to Broadcast() TreeServer* server = (omit ? TreeServer::Get(omit)->GetRoute() : nullptr); - CmdBuilder(source, "ENCAP * ").push_raw(cmd).insert(params).Forward(server); + MessageBuilder("ENCAP") + .Push('*', cmd) + .PushParams(params) + .Broadcast(server); } void SpanningTreeProtocolInterface::SendMetadata(const Extensible* ext, const std::string& key, const std::string& data) @@ -98,7 +105,9 @@ void SpanningTreeProtocolInterface::SendMetadata(const std::string& key, const s void SpanningTreeProtocolInterface::SendSNONotice(char snomask, const std::string& text) { - CmdBuilder("SNONOTICE").push(snomask).push_last(text).Broadcast(); + MessageBuilder("SNONOTICE") + .Push(snomask, text) + .Broadcast(); } void SpanningTreeProtocolInterface::SendMessage(const Channel* target, char status, const std::string& text, MessageType msgtype) @@ -111,8 +120,7 @@ void SpanningTreeProtocolInterface::SendMessage(const Channel* target, char stat void SpanningTreeProtocolInterface::SendMessage(const User* target, const std::string& text, MessageType msgtype) { - CmdBuilder p(msgtype == MessageType::PRIVMSG ? "PRIVMSG" : "NOTICE"); - p.push(target->uuid); - p.push_last(text); - p.Unicast(target); + MessageBuilder(msgtype == MessageType::PRIVMSG ? "PRIVMSG" : "NOTICE") + .Push(target->uuid, text) + .Unicast(target); } |
