registration: add a Hold verdict so captcha/challenge modules pend the client for the challenge instead of tearing the link down
This commit is contained in:
parent
99eb9c74f3
commit
4b86de3b62
4 changed files with 23 additions and 9 deletions
20
src/ircd.rs
20
src/ircd.rs
|
|
@ -545,13 +545,19 @@ impl Ircd {
|
||||||
|
|
||||||
fn complete_registration(&mut self, uid: Uid) {
|
fn complete_registration(&mut self, uid: Uid) {
|
||||||
for m in &mut self.modules {
|
for m in &mut self.modules {
|
||||||
if m.on_user_register(&mut self.server, uid) == ModResult::Deny {
|
match m.on_user_register(&mut self.server, uid) {
|
||||||
self.server.send(
|
ModResult::Deny => {
|
||||||
uid,
|
self.server.send(
|
||||||
"ERROR :Closing link (registration refused)".to_string(),
|
uid,
|
||||||
);
|
"ERROR :Closing link (registration refused)".to_string(),
|
||||||
self.server.remove_user(uid, "Registration refused");
|
);
|
||||||
return;
|
self.server.remove_user(uid, "Registration refused");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// a challenge is pending: keep the connection, don't welcome yet.
|
||||||
|
// A later command (the CAPTCHA/VERIFYCHALLENGE reply) re-runs this.
|
||||||
|
ModResult::Hold => return,
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// x-line: refuse a banned host / ip before welcoming
|
// x-line: refuse a banned host / ip before welcoming
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,12 @@ pub enum ModResult {
|
||||||
Passthru,
|
Passthru,
|
||||||
Allow,
|
Allow,
|
||||||
Deny,
|
Deny,
|
||||||
|
/// `on_user_register` only: hold the client in the pre-registration state (a
|
||||||
|
/// challenge is pending) without completing OR refusing the link. Registration
|
||||||
|
/// resumes on a later command once the hold clears (e.g. the client presents a
|
||||||
|
/// CAPTCHA/VERIFYCHALLENGE token). If they never do, the registration timeout
|
||||||
|
/// reaps them like any other stalled connection.
|
||||||
|
Hold,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A queued notify-event, drained by the core after each command.
|
/// A queued notify-event, drained by the core after each command.
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,8 @@ impl Module for CloudflareChallenge {
|
||||||
let msg = template.replace("{url}", &link);
|
let msg = template.replace("{url}", &link);
|
||||||
srv.send(uid, format!(":{} NOTICE {nick} :{msg}", srv.name));
|
srv.send(uid, format!(":{} NOTICE {nick} :{msg}", srv.name));
|
||||||
}
|
}
|
||||||
ModResult::Deny
|
// Hold the connection for the challenge (VERIFYCHALLENGE <token>), don't drop it.
|
||||||
|
ModResult::Hold
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,8 @@ impl Module for ReCaptcha {
|
||||||
let msg = template.replace("{url}", &link);
|
let msg = template.replace("{url}", &link);
|
||||||
srv.send(uid, format!(":{} NOTICE {nick} :{msg}", srv.name));
|
srv.send(uid, format!(":{} NOTICE {nick} :{msg}", srv.name));
|
||||||
}
|
}
|
||||||
ModResult::Deny
|
// Hold the connection for the challenge (CAPTCHA <token>), don't tear it down.
|
||||||
|
ModResult::Hold
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue