botserv: op assigned bots on join; statserv: persist counters across restart
Some checks failed
CI / check (push) Failing after 3m48s
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:
parent
fd455922a5
commit
8a9b6a37ca
10 changed files with 85 additions and 10 deletions
|
|
@ -245,6 +245,18 @@ impl Db {
|
|||
self.net.jupes.iter().map(|j| (j.name.clone(), j.sid.clone(), j.reason.clone())).collect()
|
||||
}
|
||||
|
||||
/// The persisted stat counters, to seed the live registry on startup.
|
||||
pub fn persisted_stats(&self) -> std::collections::BTreeMap<String, u64> {
|
||||
self.net.stats.clone()
|
||||
}
|
||||
|
||||
/// Snapshot the live stat counters to the log so they survive a restart.
|
||||
pub fn persist_stats(&mut self, counters: &std::collections::BTreeMap<String, u64>) -> std::io::Result<()> {
|
||||
self.log.append(Event::StatsSet { counters: counters.iter().map(|(k, v)| (k.clone(), *v)).collect() })?;
|
||||
self.net.stats = counters.clone();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// File an abuse report, rate-limited per reporter. Returns the new report's
|
||||
/// id, or None if the reporter filed one too recently.
|
||||
pub fn report_file(&mut self, reporter: &str, target: &str, reason: &str) -> Option<u64> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue