connectclass: per-class connection policy (allow/deny, localmax, password, maxchans, pingfreq, timeout, modes) + PASS

This commit is contained in:
Jean Chevronnet 2026-08-10 17:49:12 +00:00
parent 02b2061561
commit f5f888dbaa
9 changed files with 211 additions and 4 deletions

View file

@ -18,6 +18,7 @@ pub fn commands() -> Vec<Box<dyn Command>> {
Box::new(UserCmd),
Box::new(Ping),
Box::new(Pong),
Box::new(Pass),
Box::new(Quit),
Box::new(Away),
Box::new(SetName),
@ -562,6 +563,29 @@ impl Command for Pong {
}
}
struct Pass;
impl Command for Pass {
fn name(&self) -> &'static str {
"PASS"
}
fn min_params(&self) -> usize {
1
}
fn before_reg(&self) -> bool {
true
}
fn handle(&self, s: &mut Server, uid: Uid, params: &[String]) -> CmdResult {
// stored for a connectclass password check at registration
if let Some(u) = s.users.get_mut(&uid) {
if u.registered {
return CmdResult::Fail; // can't re-send PASS after registering
}
u.pass = Some(params[0].clone());
}
CmdResult::Ok
}
}
struct Quit;
impl Command for Quit {
fn name(&self) -> &'static str {