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

@ -106,6 +106,9 @@ async fn main() -> Result<()> {
engine.lock().await.set_opers(cfg.opers());
engine.lock().await.set_sid(cfg.server.sid.clone());
engine.lock().await.set_log_channel(cfg.log.as_ref().map(|l| l.channel.clone()));
if let Some(expire) = &cfg.expire {
engine.lock().await.set_expiry(expire.account_ttl(), expire.channel_ttl());
}
if let Some(gossip) = cfg.gossip.clone() {
tracing::info!(peers = cfg.peer.len(), "starting gossip");
@ -130,8 +133,10 @@ async fn main() -> Result<()> {
tokio::spawn(async move {
loop {
tokio::time::sleep(std::time::Duration::from_secs(1800)).await;
if let Err(e) = engine.lock().await.maybe_compact() {
tracing::warn!(%e, "compaction failed");
let mut e = engine.lock().await;
e.expire_sweep();
if let Err(err) = e.maybe_compact() {
tracing::warn!(%err, "compaction failed");
}
}
});