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:
parent
6a8e02f004
commit
87bad7fbcc
4 changed files with 30 additions and 4 deletions
|
|
@ -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."),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue