HostServ: normalise vhosts + enforce uniqueness

Canonicalise a requested vhost the way the ircd displays it (a disallowed
underscore becomes a hyphen) before storing and applying, so what we keep
matches what shows on the network. A vhost can no longer be assigned to two
accounts: prepare_vhost normalises, validates, and checks vhost_owner at
every assignment point (SET/REQUEST/ACTIVATE/TAKE/DEFAULT), so two inputs
that collapse to the same host are caught as one.

Approach recommended by siniStar (the ns_nethost normalisation logic).
This commit is contained in:
Jean Chevronnet 2026-07-13 23:05:41 +00:00
parent 271e06fa77
commit 31d23cf6b3
No known key found for this signature in database
9 changed files with 130 additions and 18 deletions

View file

@ -10,10 +10,17 @@ pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db:
ctx.notice(me, from.uid, "Syntax: TAKE <number> (see OFFERLIST)");
return;
};
let Some(host) = n.checked_sub(1).and_then(|i| db.vhost_offers().into_iter().nth(i)) else {
let Some(offer) = n.checked_sub(1).and_then(|i| db.vhost_offers().into_iter().nth(i)) else {
ctx.notice(me, from.uid, format!("There's no offer #\x02{n}\x02. See \x02OFFERLIST\x02."));
return;
};
let host = match super::prepare_vhost(&offer, account, db) {
Ok(h) => h,
Err(msg) => {
ctx.notice(me, from.uid, msg);
return;
}
};
match db.set_vhost(account, &host, "offer", None) {
Ok(()) => {
ctx.apply_vhost(from.uid, &host);