Restore the connect-time host when a session logs out, reversing any services vhost
This commit is contained in:
parent
66eb0ea243
commit
8b45d386c6
5 changed files with 48 additions and 2 deletions
|
|
@ -152,6 +152,9 @@ impl Store for Db {
|
|||
a.vhost.as_ref().filter(|v| v.expires.is_none_or(|e| e > now())).map(|v| VhostView { account: a.name.clone(), host: v.host.clone(), setter: v.setter.clone(), expires: v.expires })
|
||||
})
|
||||
}
|
||||
fn active_vhost(&self, account: &str) -> Option<String> {
|
||||
Db::active_vhost(self, account)
|
||||
}
|
||||
fn vhosts(&self) -> Vec<VhostView> {
|
||||
Db::vhosts(self).into_iter().map(|(account, host, setter, expires)| VhostView { account, host, setter, expires }).collect()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -767,6 +767,9 @@ impl Engine {
|
|||
if let Some(action) = self.feed("SESS", format!("{} logged out of \x02{account}\x02 ({reason})", self.who(uid))) {
|
||||
self.emit_irc(action);
|
||||
}
|
||||
for act in echo_api::vhost_restore_actions(&self.network, &self.db, uid, account) {
|
||||
self.emit_irc(act);
|
||||
}
|
||||
self.network.clear_account(uid);
|
||||
self.emit_irc(NetAction::Metadata { target: uid.to_string(), key: "accountname".to_string(), value: String::new() });
|
||||
if let Some(ns) = self.nick_service.clone() {
|
||||
|
|
|
|||
|
|
@ -5240,6 +5240,24 @@
|
|||
assert_eq!(e.db.unread_memos("bob"), 1, "no extra memo when online");
|
||||
}
|
||||
|
||||
// Logging out reverses a services vhost, restoring the connect-time host (the
|
||||
// cloak we were given at UserConnect), not the real host.
|
||||
#[test]
|
||||
fn logout_restores_the_connect_host_over_a_vhost() {
|
||||
let path = std::env::temp_dir().join("echo-logout-vhost.jsonl");
|
||||
let _ = std::fs::remove_file(&path);
|
||||
let mut db = Db::open(&path, "42S");
|
||||
db.scram_iterations = 4096;
|
||||
db.register("alice", "sesame", None).unwrap();
|
||||
db.set_vhost("alice", "cool.vhost", "admin", None).unwrap();
|
||||
let ns = NickServ { uid: "42SAAAAAA".into(), guest_nick: "Guest".into(), guest_seq: 0 };
|
||||
let mut e = Engine::new(vec![Box::new(ns)], db);
|
||||
e.handle(NetEvent::UserConnect { uid: "000AAAAAB".into(), nick: "alice".into(), host: "cloak.host".into(), ip: "0.0.0.0".into() });
|
||||
e.handle(NetEvent::Privmsg { from: "000AAAAAB".into(), to: "42SAAAAAA".into(), text: "IDENTIFY sesame".into() });
|
||||
let out = e.handle(NetEvent::Privmsg { from: "000AAAAAB".into(), to: "42SAAAAAA".into(), text: "LOGOUT".into() });
|
||||
assert!(out.iter().any(|a| matches!(a, NetAction::SetHost { uid, host } if uid == "000AAAAAB" && host == "cloak.host")), "logout restores the cloak: {out:?}");
|
||||
}
|
||||
|
||||
// ChanServ SET: description and founder transfer, founder-gated.
|
||||
#[test]
|
||||
fn chanserv_set() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue