Add lazy inactivity-expiry for accounts and channels

Accounts and channels now carry a last-activity stamp and are dropped
once inactive past a configured threshold. A login stamps the account, a
join stamps the channel — both coalesced to at most one log entry per day
so routine traffic doesn't bloat the log, and stamps replicate so
activity on any node keeps a record alive network-wide.

Expiry is lazy in the proven style: a periodic pass computes it from the
stored stamps with no per-record timer, reusing the same relation the
vhost and suspension expiries use. The sweep spares operator accounts,
accounts with a live session, occupied channels, and anything an operator
has pinned with the new NOEXPIRE command (NickServ NOEXPIRE <account>,
ChanServ NOEXPIRE <#channel>, both Priv::Admin). Each expiry is announced
to the audit channel and clears the channel's +r.

Configured under [expire] (accounts_days / channels_days); a zero or
omitted field leaves that kind never expiring, and omitting the section
disables expiry entirely.
This commit is contained in:
Jean Chevronnet 2026-07-14 00:02:36 +00:00
parent 698d604954
commit 253d4c2a2d
No known key found for this signature in database
11 changed files with 413 additions and 13 deletions

View file

@ -29,6 +29,30 @@ pub struct Config {
// Staff audit feed. Absent = no audit log is emitted.
#[serde(default)]
pub log: Option<Log>,
// Inactivity-expiry. Absent = accounts and channels never expire.
#[serde(default)]
pub expire: Option<Expire>,
}
// Inactivity-expiry thresholds, in days. A zero (or omitted) field leaves that
// kind never expiring, so an operator can expire only accounts, only channels,
// or both.
#[derive(Debug, Deserialize, Clone)]
pub struct Expire {
#[serde(default)]
pub accounts_days: u64,
#[serde(default)]
pub channels_days: u64,
}
impl Expire {
// The thresholds in seconds, or None where that kind is disabled (zero days).
pub fn account_ttl(&self) -> Option<u64> {
(self.accounts_days > 0).then(|| self.accounts_days * 86_400)
}
pub fn channel_ttl(&self) -> Option<u64> {
(self.channels_days > 0).then(|| self.channels_days * 86_400)
}
}
// The staff audit feed: notable service actions are announced to this channel