HostServ: throttle vhost requests

A member may request a vhost at most once a minute; a request sooner is
refused with the wait time. In-memory per-account (not event-logged), the
same shape as the identify brute-force throttle.
This commit is contained in:
Jean Chevronnet 2026-07-13 22:47:02 +00:00
parent 6a8e02f004
commit 87bad7fbcc
No known key found for this signature in database
4 changed files with 30 additions and 4 deletions

View file

@ -18,6 +18,11 @@ pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db:
ctx.notice(me, from.uid, format!("\x02{host}\x02 isn't allowed here. Please choose another."));
return;
}
let wait = db.vhost_request_wait(account);
if wait > 0 {
ctx.notice(me, from.uid, format!("Please wait \x02{wait}\x02s before requesting another vhost."));
return;
}
match db.request_vhost(account, host) {
Ok(()) => ctx.notice(me, from.uid, format!("Requested vhost \x02{host}\x02 — an operator will review it.")),
Err(_) => ctx.notice(me, from.uid, "Sorry, that didn't work. Please try again in a moment."),