OperServ: JUPE — hold a server name against a rogue link
JUPE <server.name> [reason] introduces a fake server holding the name so the real one can't link; JUPE DEL <name> squits it; JUPE LIST shows them. Node-local (the introducing node owns the jupe, so it isn't federated — that would collide SIDs across nodes) and re-asserted at burst. A fake server id is allocated per jupe. New JupeServer/Squit actions serialise to the mid-link SERVER introduction and SQUIT. Admin-only.
This commit is contained in:
parent
76a7162227
commit
1daebc94a5
6 changed files with 179 additions and 2 deletions
|
|
@ -719,6 +719,10 @@ impl Engine {
|
|||
let duration = a.expires.map(|e| e.saturating_sub(now)).unwrap_or(0);
|
||||
out.push(NetAction::AddLine { kind: a.kind, mask: a.mask, setter: a.setter, duration, reason: a.reason });
|
||||
}
|
||||
// Re-introduce our juped servers over the fresh link.
|
||||
for (name, sid, reason) in self.db.jupes() {
|
||||
out.push(NetAction::JupeServer { name, sid, reason });
|
||||
}
|
||||
out.push(NetAction::Metadata {
|
||||
target: "*".to_string(),
|
||||
key: "saslmechlist".to_string(),
|
||||
|
|
@ -4086,6 +4090,48 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
// OperServ JUPE: hold a server name with a fake server, re-assert it at burst,
|
||||
// and lift it with a squit. Admin-only.
|
||||
#[test]
|
||||
fn operserv_jupe_holds_and_lifts() {
|
||||
use fedserv_operserv::OperServ;
|
||||
let path = std::env::temp_dir().join("fedserv-osjupe.jsonl");
|
||||
let _ = std::fs::remove_file(&path);
|
||||
let mut db = Db::open(&path, "42S");
|
||||
db.scram_iterations = 4096;
|
||||
db.register("staff", "password1", None).unwrap();
|
||||
let mut e = Engine::new(
|
||||
vec![
|
||||
Box::new(NickServ { uid: "42SAAAAAA".into(), guest_nick: "Guest".into(), guest_seq: 0 }),
|
||||
Box::new(OperServ { uid: "42SAAAAAH".into() }),
|
||||
],
|
||||
db,
|
||||
);
|
||||
e.set_sid("42S".into());
|
||||
let mut opers = std::collections::HashMap::new();
|
||||
opers.insert("staff".to_string(), Privs::default().with(fedserv_api::Priv::Admin));
|
||||
e.set_opers(opers);
|
||||
let os = |e: &mut Engine, uid: &str, t: &str| e.handle(NetEvent::Privmsg { from: uid.into(), to: "42SAAAAAH".into(), text: t.into() });
|
||||
|
||||
e.handle(NetEvent::UserConnect { uid: "000AAAAAS".into(), nick: "staff".into(), host: "h".into(), ip: "9.9.9.9".into() });
|
||||
e.handle(NetEvent::Privmsg { from: "000AAAAAS".into(), to: "42SAAAAAA".into(), text: "IDENTIFY password1".into() });
|
||||
|
||||
// Juping introduces a fake server holding the name.
|
||||
let out = os(&mut e, "000AAAAAS", "JUPE rogue.example evil twin");
|
||||
assert!(out.iter().any(|a| matches!(a, NetAction::JupeServer { name, .. } if name == "rogue.example")), "jupe introduced: {out:?}");
|
||||
// A bare name (no dot) isn't a server — syntax refused.
|
||||
assert!(os(&mut e, "000AAAAAS", "JUPE notaserver").iter().any(|a| matches!(a, NetAction::Notice { text, .. } if text.contains("Syntax"))), "needs a server name");
|
||||
|
||||
// It's re-introduced at burst.
|
||||
assert!(e.startup_actions().iter().any(|a| matches!(a, NetAction::JupeServer { name, .. } if name == "rogue.example")), "re-asserted at burst");
|
||||
// LIST shows it.
|
||||
assert!(os(&mut e, "000AAAAAS", "JUPE LIST").iter().any(|a| matches!(a, NetAction::Notice { text, .. } if text.contains("rogue.example"))), "listed");
|
||||
|
||||
// DEL squits the fake server.
|
||||
assert!(os(&mut e, "000AAAAAS", "JUPE DEL rogue.example").iter().any(|a| matches!(a, NetAction::Squit { .. })), "squit on lift");
|
||||
assert!(!e.startup_actions().iter().any(|a| matches!(a, NetAction::JupeServer { .. })), "gone after DEL");
|
||||
}
|
||||
|
||||
// OperServ session limiting: the connection that puts an IP over its limit is
|
||||
// killed; SESSION inspects counts; EXCEPTION raises the allowance per IP-mask.
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue