botserv: op assigned bots on join; statserv: persist counters across restart
Some checks failed
CI / check (push) Failing after 3m48s

Problem 1: an assigned bot joined via IJOIN with no status mode, so it had no
+o. Join it with the 4-param IJOIN form (ts 1, mode o) so it's opped, matching
Anope's default bot modes (+o), and exempt bots from SECUREOPS/RESTRICTED so the
op is never stripped.

Problem 2: the shared stat counters lived only in memory, so a restart wiped
them. Snapshot them to the log (StatsSet event, folded into NetData + compaction)
periodically and on shutdown, and reseed the live registry from the log at
startup. Live gauges (online counts) stay re-derived, not stored.
This commit is contained in:
Jean Chevronnet 2026-07-16 17:32:20 +00:00
parent fd455922a5
commit 8a9b6a37ca
No known key found for this signature in database
10 changed files with 85 additions and 10 deletions

View file

@ -40,7 +40,7 @@ fn redact(line: &str) -> Cow<'_, str> {
let is_set_password = cmd == "set"
&& words.next().map(|w| w.eq_ignore_ascii_case("password")).unwrap_or(false);
if (SECRET_CMDS.contains(&cmd.as_str()) || is_set_password) && argstart < line.len() {
return format!("{} :[REDACTED]", &line[..tstart].trim_end_matches(" :")).into();
return format!("{} :[REDACTED]", line[..tstart].trim_end_matches(" :")).into();
}
}
}
@ -130,6 +130,7 @@ pub async fn run(mut proto: Box<dyn Protocol>, engine: Arc<Mutex<Engine>>, addr:
continue;
}
if let NetAction::Shutdown { restart, reason } = act {
engine.lock().await.persist_stats();
let _ = write.flush().await;
shutdown(restart, &reason);
}
@ -146,6 +147,7 @@ pub async fn run(mut proto: Box<dyn Protocol>, engine: Arc<Mutex<Engine>>, addr:
if let NetAction::SendEmail { to, subject, text, html } = action {
dispatch_email(&email, to, subject, text, html);
} else if let NetAction::Shutdown { restart, reason } = action {
engine.lock().await.persist_stats();
let _ = write.flush().await;
shutdown(restart, &reason);
} else {