NickServ: add SET KILL to toggle nick protection

Nick protection was unconditional. SET KILL OFF lets an account opt out —
an unidentified user keeping one of its nicks is no longer prompted or
renamed to a guest. Stored inverted (no_protect) so protection stays the
default. Accepts Anope's ON/QUICK/IMMED/OFF; grace is a fixed interval
here, so the finer variants simply enable protection like ON.
This commit is contained in:
Jean Chevronnet 2026-07-16 01:43:10 +00:00
parent 87e21ff85f
commit 2c4bc9079c
No known key found for this signature in database
11 changed files with 106 additions and 9 deletions

View file

@ -21,7 +21,7 @@ impl Db {
ajoin: Vec::new(),
suspension: None,
memos: Vec::new(), memo_ignore: Vec::new(), memo_notify: true, memo_limit: None,
greet: String::new(), no_autoop: false,
greet: String::new(), no_autoop: false, no_protect: false,
vhost: None,
vhost_request: None,
last_seen: now(),
@ -60,7 +60,7 @@ impl Db {
ajoin: Vec::new(),
suspension: None,
memos: Vec::new(), memo_ignore: Vec::new(), memo_notify: true, memo_limit: None,
greet: String::new(), no_autoop: false,
greet: String::new(), no_autoop: false, no_protect: false,
vhost: None,
vhost_request: None,
last_seen: now(),
@ -434,6 +434,22 @@ impl Db {
self.accounts.get(&key(account)).is_none_or(|a| !a.no_autoop)
}
/// Set whether `account`'s nicks are protected by the enforcer (SET KILL).
pub fn set_account_kill(&mut self, account: &str, on: bool) -> Result<(), RegError> {
let k = key(account);
if !self.accounts.contains_key(&k) {
return Err(RegError::Internal);
}
self.log.append(Event::AccountKillSet { account: account.to_string(), on }).map_err(|_| RegError::Internal)?;
self.accounts.get_mut(&k).unwrap().no_protect = !on;
Ok(())
}
/// Whether `account`'s nicks are protected by the enforcer (default true).
pub fn account_wants_protect(&self, account: &str) -> bool {
self.accounts.get(&key(account)).is_none_or(|a| !a.no_protect)
}
/// Replace `account`'s password with freshly derived credentials.
pub fn set_credentials(&mut self, account: &str, creds: Credentials) -> Result<(), RegError> {
let k = key(account);