protocol: verify echo ircd module dependencies from CAPAB MODULES at link, warning per-feature if one is missing rather than failing silently
All checks were successful
CI / check (push) Successful in 3m49s

This commit is contained in:
Jean Chevronnet 2026-07-18 02:22:43 +00:00
parent 0ca06247f8
commit 2f70b0c133
No known key found for this signature in database
4 changed files with 97 additions and 0 deletions

View file

@ -1116,6 +1116,14 @@ impl Engine {
self.db.set_live_chanmodes(modes);
Vec::new()
}
NetEvent::ModulesAvailable { modules } => {
self.network.learn_modules(modules);
Vec::new()
}
NetEvent::CapabEnd => {
verify_ircd_dependencies(&self.network);
Vec::new()
}
NetEvent::Casemapping { name } => {
// echo folds identifiers as ascii. Verify the ircd agrees, rather than
// assuming it silently — a mismatch would desync account/channel identity.
@ -1619,6 +1627,39 @@ fn event_category(event: &db::Event) -> &'static str {
}
}
// echo's ircd module dependencies: (module, critical?, the feature it enables).
const IRCD_DEPS: &[(&str, bool, &str)] = &[
("account", true, "account login tracking"),
("services", true, "services-server privileges (SVS*, u-line)"),
("rline", false, "regex realname bans (SNLINE)"),
("chghost", false, "vhosts (HostServ)"),
("chgident", false, "vidents (HostServ)"),
("cban", false, "channel-name bans (CBAN)"),
("ircv3_ctctags", false, "tag messages (GameServ)"),
];
// At CAPAB END, check the modules the ircd advertised against echo's dependencies,
// so a missing one is a clear diagnostic at link rather than a silent malfunction.
fn verify_ircd_dependencies(net: &Network) {
if net.module_count() == 0 {
return; // the ircd didn't advertise its modules — nothing to verify against
}
let mut missing = 0;
for &(module, critical, feature) in IRCD_DEPS {
if !net.has_module(module) {
missing += 1;
if critical {
tracing::error!(module, "REQUIRED ircd module not loaded — {feature} will not work");
} else {
tracing::warn!(module, "ircd module not loaded — {feature} is unavailable");
}
}
}
if missing == 0 {
tracing::info!(count = net.module_count(), "verified ircd module dependencies");
}
}
// A one-line, human-readable summary of a logged event for the staff audit
// feed, or None for events that are private (memos), cosmetic self-service
// (greets, auto-join, personal settings), or otherwise not worth surfacing.