HostServ: forbidden-vhost patterns + auto-vhost template

FORBID <regex> / FORBIDLIST / FORBIDDEL let operators block impersonating
user requests (e.g. (?i)(admin|staff)); REQUEST refuses a matching host.
Matching reuses the linear-time RegexSet, so untrusted patterns are safe.

TEMPLATE <$account...> sets a network auto-vhost pattern; DEFAULT gives a
user $account.users.example with their sanitised account name. HostServ's
node config (offers/forbidden/template) is consolidated into one HostConfig
threaded through the log replay.
This commit is contained in:
Jean Chevronnet 2026-07-13 22:42:25 +00:00
parent 2c32dcdc63
commit 6a8e02f004
No known key found for this signature in database
9 changed files with 302 additions and 22 deletions

View file

@ -25,6 +25,12 @@ mod approve;
mod offer;
#[path = "take.rs"]
mod take;
#[path = "forbid.rs"]
mod forbid;
#[path = "template.rs"]
mod template;
#[path = "default.rs"]
mod default;
pub struct HostServ {
pub uid: String,
@ -60,6 +66,11 @@ impl Service for HostServ {
Some("OFFERLIST") => offer::list(me, from, ctx, db),
Some("OFFERDEL") => offer::del(me, from, args, ctx, db),
Some("TAKE") => take::handle(me, from, args, ctx, db),
Some("FORBID") => forbid::add(me, from, args, ctx, db),
Some("FORBIDLIST") => forbid::list(me, from, ctx, db),
Some("FORBIDDEL") => forbid::del(me, from, args, ctx, db),
Some("TEMPLATE") => template::handle(me, from, args, ctx, db),
Some("DEFAULT") => default::handle(me, from, ctx, db),
Some("HELP") | None => ctx.notice(me, from.uid, "HostServ gives you a vhost: \x02ON\x02 activates your assigned vhost, \x02OFF\x02 restores your normal host, \x02REQUEST\x02 <host> asks for one, \x02OFFERLIST\x02 + \x02TAKE\x02 <n> pick from the menu. Operators use \x02SET\x02/\x02DEL\x02 <account>, \x02LIST\x02, \x02WAITING\x02 + \x02ACTIVATE\x02/\x02REJECT\x02, and \x02OFFER\x02/\x02OFFERDEL\x02 for the menu."),
Some(other) => ctx.notice(me, from.uid, format!("I don't know the command \x02{other}\x02. Try \x02HELP\x02.")),
}