aboutsummaryrefslogtreecommitdiffstats
path: root/modules/spanningtree/capab.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/capab.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/capab.cpp')
-rw-r--r--modules/spanningtree/capab.cpp60
1 files changed, 40 insertions, 20 deletions
diff --git a/modules/spanningtree/capab.cpp b/modules/spanningtree/capab.cpp
index 54d55ef58..f717bf048 100644
--- a/modules/spanningtree/capab.cpp
+++ b/modules/spanningtree/capab.cpp
@@ -363,23 +363,43 @@ void TreeSocket::SendCapabilities(int phase)
return;
if (capab->capab_phase < 1 && phase >= 1)
- WriteLine(FMT::format("CAPAB START {}", (uint16_t)PROTO_NEWEST));
+ {
+ MessageBuilder("CAPAB")
+ .Push("START", (uint16_t)PROTO_NEWEST)
+ .Unicast(this);
+ }
capab->capab_phase = phase;
if (phase < 2)
return;
- WriteLine("CAPAB CAPABILITIES :" + FormatCapabilities(this));
- WriteLine("CAPAB MODULES :" + FormatModules(VF_COMMON, proto_version));
- WriteLine("CAPAB MODSUPPORT :" + FormatModules(VF_OPTCOMMON, proto_version));
- WriteLine("CAPAB CHANMODES :" + BuildModeList(MODETYPE_CHANNEL));
- WriteLine("CAPAB USERMODES :" + BuildModeList(MODETYPE_USER));
+ MessageBuilder("CAPAB", true)
+ .Push("CAPABILITIES", FormatCapabilities(this))
+ .Unicast(this);
+ MessageBuilder("CAPAB", true)
+ .Push("MODULES", FormatModules(VF_COMMON, proto_version))
+ .Unicast(this);
+ MessageBuilder("CAPAB", true)
+ .Push("MODSUPPORT", FormatModules(VF_OPTCOMMON, proto_version))
+ .Unicast(this);
+ MessageBuilder("CAPAB", true)
+ .Push("CHANMODES", BuildModeList(MODETYPE_CHANNEL))
+ .Unicast(this);
+ MessageBuilder("CAPAB", true)
+ .Push("USERMODES", BuildModeList(MODETYPE_USER))
+ .Unicast(this);
std::string extbans;
if (BuildExtBanList(extbans))
- WriteLine("CAPAB EXTBANS :" + extbans);
+ {
+ MessageBuilder("CAPAB", true)
+ .Push("EXTBANS", extbans)
+ .Unicast(this);
+ }
- this->WriteLine("CAPAB END");
+ MessageBuilder("CAPAB", true)
+ .Push("END")
+ .Unicast(this);
}
/* Isolate and return the elements that are different between two comma separated lists */
@@ -551,12 +571,12 @@ bool TreeSocket::Capab(const CommandBase::Params& params)
if (!this->GetTheirChallenge().empty() && (this->LinkState == CONNECTING))
{
this->SendCapabilities(2);
- this->WriteLine(FMT::format("SERVER {} {} {} :{}",
- ServerInstance->Config->ServerName,
- TreeSocket::MakePass(capab->link->SendPass, capab->theirchallenge),
- ServerInstance->Config->ServerId,
- ServerInstance->Config->ServerDesc
- ));
+ MessageBuilder("SERVER", true)
+ .Push(ServerInstance->Config->ServerName,
+ TreeSocket::MakePass(capab->link->SendPass, capab->theirchallenge),
+ ServerInstance->Config->ServerId,
+ ServerInstance->Config->ServerDesc)
+ .Unicast(this);
}
}
else
@@ -565,12 +585,12 @@ bool TreeSocket::Capab(const CommandBase::Params& params)
if (this->LinkState == CONNECTING)
{
this->SendCapabilities(2);
- this->WriteLine(FMT::format("SERVER {} {} {} :{}",
- ServerInstance->Config->ServerName,
- capab->link->SendPass,
- ServerInstance->Config->ServerId,
- ServerInstance->Config->ServerDesc
- ));
+ MessageBuilder("SERVER", true)
+ .Push(ServerInstance->Config->ServerName,
+ capab->link->SendPass,
+ ServerInstance->Config->ServerId,
+ ServerInstance->Config->ServerDesc)
+ .Unicast(this);
}
}
}