HostServ: ident@host vhosts (CHGIDENT)

A vhost may be ident@host, not just host: apply_vhost splits it and sends
CHGIDENT for the ident plus CHGHOST for the host. valid_vhost validates
the optional ident part; ON/SET/ACTIVATE/identify all route through
apply_vhost, so a bare host still works unchanged. New SetIdent action.
This commit is contained in:
Jean Chevronnet 2026-07-13 22:04:16 +00:00
parent 1edf250952
commit 898461d1c2
No known key found for this signature in database
8 changed files with 65 additions and 8 deletions

View file

@ -2686,6 +2686,34 @@ mod tests {
assert!(hs(&mut e, "000AAAAAB", "SET alice not a host").iter().any(|a| matches!(a, NetAction::Notice { text, .. } if text.contains("isn't a valid host"))), "host validated");
}
// An ident@host vhost applies both the ident (CHGIDENT) and the host.
#[test]
fn hostserv_ident_at_host() {
use fedserv_hostserv::HostServ;
use fedserv_nickserv::NickServ;
let path = std::env::temp_dir().join("fedserv-hsident.jsonl");
let _ = std::fs::remove_file(&path);
let mut db = Db::open(&path, "42S");
db.scram_iterations = 4096;
db.register("boss", "password1", None).unwrap();
db.register("alice", "password1", None).unwrap();
db.set_vhost("alice", "web@cloak.example", "system").unwrap();
let mut e = Engine::new(
vec![
Box::new(NickServ { uid: "42SAAAAAA".into(), guest_nick: "Guest".into(), guest_seq: 0 }),
Box::new(HostServ { uid: "42SAAAAAG".into() }),
],
db,
);
e.set_sid("42S".into());
let ns = |e: &mut Engine, uid: &str, t: &str| e.handle(NetEvent::Privmsg { from: uid.into(), to: "42SAAAAAA".into(), text: t.into() });
e.handle(NetEvent::UserConnect { uid: "000AAAAAV".into(), nick: "alice".into(), host: "realhost".into() });
let out = ns(&mut e, "000AAAAAV", "IDENTIFY password1");
assert!(out.iter().any(|a| matches!(a, NetAction::SetIdent { uid, ident } if uid == "000AAAAAV" && ident == "web")), "ident set: {out:?}");
assert!(out.iter().any(|a| matches!(a, NetAction::SetHost { uid, host } if uid == "000AAAAAV" && host == "cloak.example")), "host set");
}
// HostServ REQUEST -> WAITING -> ACTIVATE assigns and applies the vhost; a
// REJECT clears the request without assigning anything.
#[test]