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
|
|
@ -307,6 +307,9 @@ pub struct NetData {
|
|||
// The bot auto-assigned to newly registered channels (BotServ AUTOASSIGN),
|
||||
// if any. Casefolded nick; None disables auto-assignment.
|
||||
pub default_bot: Option<String>,
|
||||
// Persisted shared stat counters (StatServ / gRPC Stats), snapshotted so they
|
||||
// survive a restart (live gauges are re-derived, not stored here).
|
||||
pub stats: std::collections::BTreeMap<String, u64>,
|
||||
}
|
||||
|
||||
// A session-limit exception: an IP-mask glob and the session allowance for IPs
|
||||
|
|
@ -1165,6 +1168,9 @@ impl Db {
|
|||
if self.net.default_bot.is_some() {
|
||||
snapshot.push(Event::DefaultBotSet { bot: self.net.default_bot.clone() });
|
||||
}
|
||||
if !self.net.stats.is_empty() {
|
||||
snapshot.push(Event::StatsSet { counters: self.net.stats.iter().map(|(k, v)| (k.clone(), *v)).collect() });
|
||||
}
|
||||
for host in &self.host_cfg.offers {
|
||||
snapshot.push(Event::VhostOfferAdded { host: host.clone() });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue