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:
parent
87e21ff85f
commit
2c4bc9079c
11 changed files with 106 additions and 9 deletions
|
|
@ -917,6 +917,9 @@ pub trait Store {
|
||||||
// NickServ SET AUTOOP: whether this account is auto-opped on join.
|
// NickServ SET AUTOOP: whether this account is auto-opped on join.
|
||||||
fn set_account_autoop(&mut self, account: &str, on: bool) -> Result<(), RegError>;
|
fn set_account_autoop(&mut self, account: &str, on: bool) -> Result<(), RegError>;
|
||||||
fn account_wants_autoop(&self, account: &str) -> bool;
|
fn account_wants_autoop(&self, account: &str) -> bool;
|
||||||
|
// NickServ SET KILL: whether this account's nicks are enforcer-protected.
|
||||||
|
fn set_account_kill(&mut self, account: &str, on: bool) -> Result<(), RegError>;
|
||||||
|
fn account_wants_protect(&self, account: &str) -> bool;
|
||||||
// HostServ vhosts.
|
// HostServ vhosts.
|
||||||
fn set_vhost(&mut self, account: &str, host: &str, setter: &str, ttl: Option<u64>) -> Result<(), RegError>;
|
fn set_vhost(&mut self, account: &str, host: &str, setter: &str, ttl: Option<u64>) -> Result<(), RegError>;
|
||||||
fn del_vhost(&mut self, account: &str) -> Result<bool, RegError>;
|
fn del_vhost(&mut self, account: &str) -> Result<bool, RegError>;
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ const TOPICS: &[HelpEntry] = &[
|
||||||
HelpEntry { cmd: "LOGOUT", summary: "log out to a guest nick", detail: "Syntax: \x02LOGOUT\x02\nLogs you out and moves you to a guest nick. Also \x02LOGOFF\x02." },
|
HelpEntry { cmd: "LOGOUT", summary: "log out to a guest nick", detail: "Syntax: \x02LOGOUT\x02\nLogs you out and moves you to a guest nick. Also \x02LOGOFF\x02." },
|
||||||
HelpEntry { cmd: "INFO", summary: "show account information", detail: "Syntax: \x02INFO [account]\x02\nShows account information. The email is shown only to the owner." },
|
HelpEntry { cmd: "INFO", summary: "show account information", detail: "Syntax: \x02INFO [account]\x02\nShows account information. The email is shown only to the owner." },
|
||||||
HelpEntry { cmd: "ALIST", summary: "list channels you have access on", detail: "Syntax: \x02ALIST\x02\nLists the channels you hold access on." },
|
HelpEntry { cmd: "ALIST", summary: "list channels you have access on", detail: "Syntax: \x02ALIST\x02\nLists the channels you hold access on." },
|
||||||
HelpEntry { cmd: "SET", summary: "change password, email, or preferences", detail: "Syntax: \x02SET PASSWORD <new>\x02, \x02SET EMAIL <address>\x02, \x02SET GREET [message]\x02, or \x02SET AUTOOP {ON|OFF}\x02\nChanges your account password, email, greet, or auto-op preference." },
|
HelpEntry { cmd: "SET", summary: "change password, email, or preferences", detail: "Syntax: \x02SET PASSWORD <new>\x02, \x02SET EMAIL <address>\x02, \x02SET GREET [message]\x02, \x02SET AUTOOP {ON|OFF}\x02, or \x02SET KILL {ON|OFF}\x02\nChanges your password, email, greet, auto-op, or nick-protection preference." },
|
||||||
HelpEntry { cmd: "SASET", summary: "change another account's settings (operator)", detail: "Syntax: \x02SASET <account> PASSWORD <new>\x02, \x02EMAIL [address]\x02, or \x02GREET [message]\x02\nEdits another account's settings. Operators only." },
|
HelpEntry { cmd: "SASET", summary: "change another account's settings (operator)", detail: "Syntax: \x02SASET <account> PASSWORD <new>\x02, \x02EMAIL [address]\x02, or \x02GREET [message]\x02\nEdits another account's settings. Operators only." },
|
||||||
HelpEntry { cmd: "GROUP", summary: "link this nick to an account", detail: "Syntax: \x02GROUP <account> <password>\x02\nLinks your current nick to an account as an alias, so identifying under it logs into that account." },
|
HelpEntry { cmd: "GROUP", summary: "link this nick to an account", detail: "Syntax: \x02GROUP <account> <password>\x02\nLinks your current nick to an account as an alias, so identifying under it logs into that account." },
|
||||||
HelpEntry { cmd: "GLIST", summary: "list your grouped nicks", detail: "Syntax: \x02GLIST\x02\nLists the nicks grouped to your account." },
|
HelpEntry { cmd: "GLIST", summary: "list your grouped nicks", detail: "Syntax: \x02GLIST\x02\nLists the nicks grouped to your account." },
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,25 @@ pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db:
|
||||||
Err(_) => ctx.notice(me, from.uid, "Sorry, that didn't work. Please try again in a moment."),
|
Err(_) => ctx.notice(me, from.uid, "Sorry, that didn't work. Please try again in a moment."),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some("KILL") => {
|
||||||
|
// Anope accepts ON/QUICK/IMMED/OFF; grace here is a fixed interval, so
|
||||||
|
// the finer variants simply enable protection like ON.
|
||||||
|
let on = match args.get(2).map(|s| s.to_ascii_uppercase()) {
|
||||||
|
Some(v) if v == "ON" || v == "QUICK" || v == "IMMED" || v == "IMMEDIATE" => Some(true),
|
||||||
|
Some(v) if v == "OFF" => Some(false),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
let Some(on) = on else {
|
||||||
|
let state = if db.account_wants_protect(account) { "ON" } else { "OFF" };
|
||||||
|
ctx.notice(me, from.uid, format!("KILL (nick protection) is \x02{state}\x02. Syntax: SET KILL {{ON|OFF}}"));
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
match db.set_account_kill(account, on) {
|
||||||
|
Ok(()) if on => ctx.notice(me, from.uid, "Nick protection is \x02on\x02: someone using your nick without identifying will be renamed."),
|
||||||
|
Ok(()) => ctx.notice(me, from.uid, "Nick protection is \x02off\x02: your registered nicks won't be enforced."),
|
||||||
|
Err(_) => ctx.notice(me, from.uid, "Sorry, that didn't work. Please try again in a moment."),
|
||||||
|
}
|
||||||
|
}
|
||||||
Some("AUTOOP") => {
|
Some("AUTOOP") => {
|
||||||
let Some(on) = args.get(2).and_then(|s| parse_toggle(s)) else {
|
let Some(on) = args.get(2).and_then(|s| parse_toggle(s)) else {
|
||||||
let state = if db.account_wants_autoop(account) { "ON" } else { "OFF" };
|
let state = if db.account_wants_autoop(account) { "ON" } else { "OFF" };
|
||||||
|
|
@ -57,7 +76,7 @@ pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db:
|
||||||
Err(_) => ctx.notice(me, from.uid, "Sorry, that didn't work. Please try again in a moment."),
|
Err(_) => ctx.notice(me, from.uid, "Sorry, that didn't work. Please try again in a moment."),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => ctx.notice(me, from.uid, "Syntax: SET PASSWORD <newpassword> | SET EMAIL [address] | SET GREET [message] | SET AUTOOP {ON|OFF}"),
|
_ => ctx.notice(me, from.uid, "Syntax: SET PASSWORD <newpassword> | SET EMAIL [address] | SET GREET [message] | SET AUTOOP {ON|OFF} | SET KILL {ON|OFF}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ impl Db {
|
||||||
ajoin: Vec::new(),
|
ajoin: Vec::new(),
|
||||||
suspension: None,
|
suspension: None,
|
||||||
memos: Vec::new(), memo_ignore: Vec::new(), memo_notify: true, memo_limit: 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: None,
|
||||||
vhost_request: None,
|
vhost_request: None,
|
||||||
last_seen: now(),
|
last_seen: now(),
|
||||||
|
|
@ -60,7 +60,7 @@ impl Db {
|
||||||
ajoin: Vec::new(),
|
ajoin: Vec::new(),
|
||||||
suspension: None,
|
suspension: None,
|
||||||
memos: Vec::new(), memo_ignore: Vec::new(), memo_notify: true, memo_limit: 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: None,
|
||||||
vhost_request: None,
|
vhost_request: None,
|
||||||
last_seen: now(),
|
last_seen: now(),
|
||||||
|
|
@ -434,6 +434,22 @@ impl Db {
|
||||||
self.accounts.get(&key(account)).is_none_or(|a| !a.no_autoop)
|
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.
|
/// Replace `account`'s password with freshly derived credentials.
|
||||||
pub fn set_credentials(&mut self, account: &str, creds: Credentials) -> Result<(), RegError> {
|
pub fn set_credentials(&mut self, account: &str, creds: Credentials) -> Result<(), RegError> {
|
||||||
let k = key(account);
|
let k = key(account);
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ pub enum Event {
|
||||||
AccountEmailSet { account: String, email: Option<String> },
|
AccountEmailSet { account: String, email: Option<String> },
|
||||||
AccountGreetSet { account: String, greet: String },
|
AccountGreetSet { account: String, greet: String },
|
||||||
AccountAutoOpSet { account: String, on: bool },
|
AccountAutoOpSet { account: String, on: bool },
|
||||||
|
AccountKillSet { account: String, on: bool },
|
||||||
AccountPasswordSet { account: String, scram256: String, scram512: String },
|
AccountPasswordSet { account: String, scram256: String, scram512: String },
|
||||||
AccountDropped { account: String },
|
AccountDropped { account: String },
|
||||||
AccountVerified { account: String },
|
AccountVerified { account: String },
|
||||||
|
|
@ -149,6 +150,7 @@ impl Event {
|
||||||
| Event::AccountEmailSet { .. }
|
| Event::AccountEmailSet { .. }
|
||||||
| Event::AccountGreetSet { .. }
|
| Event::AccountGreetSet { .. }
|
||||||
| Event::AccountAutoOpSet { .. }
|
| Event::AccountAutoOpSet { .. }
|
||||||
|
| Event::AccountKillSet { .. }
|
||||||
| Event::AccountPasswordSet { .. }
|
| Event::AccountPasswordSet { .. }
|
||||||
| Event::AccountDropped { .. }
|
| Event::AccountDropped { .. }
|
||||||
| Event::AccountVerified { .. }
|
| Event::AccountVerified { .. }
|
||||||
|
|
@ -280,6 +282,11 @@ pub(crate) fn apply(accounts: &mut HashMap<String, Account>, channels: &mut Hash
|
||||||
a.no_autoop = !on;
|
a.no_autoop = !on;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Event::AccountKillSet { account, on } => {
|
||||||
|
if let Some(a) = accounts.get_mut(&key(&account)) {
|
||||||
|
a.no_protect = !on;
|
||||||
|
}
|
||||||
|
}
|
||||||
Event::AccountPasswordSet { account, scram256, scram512 } => {
|
Event::AccountPasswordSet { account, scram256, scram512 } => {
|
||||||
if let Some(a) = accounts.get_mut(&key(&account)) {
|
if let Some(a) = accounts.get_mut(&key(&account)) {
|
||||||
a.scram256 = Some(scram256);
|
a.scram256 = Some(scram256);
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,11 @@ pub struct Account {
|
||||||
// (auto-op enabled) is the zero value.
|
// (auto-op enabled) is the zero value.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub no_autoop: bool,
|
pub no_autoop: bool,
|
||||||
|
// NickServ SET KILL: when off, this account's nicks are not protected — an
|
||||||
|
// unidentified user keeping the nick is never renamed to a guest. Stored
|
||||||
|
// inverted so the default (protection enabled) is the zero value.
|
||||||
|
#[serde(default)]
|
||||||
|
pub no_protect: bool,
|
||||||
// Assigned vhost (HostServ), applied to the displayed host on identify.
|
// Assigned vhost (HostServ), applied to the displayed host on identify.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub vhost: Option<Vhost>,
|
pub vhost: Option<Vhost>,
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,12 @@ impl Store for Db {
|
||||||
fn account_wants_autoop(&self, account: &str) -> bool {
|
fn account_wants_autoop(&self, account: &str) -> bool {
|
||||||
Db::account_wants_autoop(self, account)
|
Db::account_wants_autoop(self, account)
|
||||||
}
|
}
|
||||||
|
fn set_account_kill(&mut self, account: &str, on: bool) -> Result<(), RegError> {
|
||||||
|
Db::set_account_kill(self, account, on)
|
||||||
|
}
|
||||||
|
fn account_wants_protect(&self, account: &str) -> bool {
|
||||||
|
Db::account_wants_protect(self, account)
|
||||||
|
}
|
||||||
fn set_vhost(&mut self, account: &str, host: &str, setter: &str, ttl: Option<u64>) -> Result<(), RegError> {
|
fn set_vhost(&mut self, account: &str, host: &str, setter: &str, ttl: Option<u64>) -> Result<(), RegError> {
|
||||||
Db::set_vhost(self, account, host, setter, ttl)
|
Db::set_vhost(self, account, host, setter, ttl)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
// which of the two competing registrations we're looking at.
|
// which of the two competing registrations we're looking at.
|
||||||
let alice = |tag: &str, ts: u64, home: &str| Account {
|
let alice = |tag: &str, ts: u64, home: &str| Account {
|
||||||
name: "alice".into(), email: Some(tag.into()),
|
name: "alice".into(), email: Some(tag.into()),
|
||||||
ts, home: home.into(), scram256: None, scram512: None, certfps: vec![], verified: true, ajoin: vec![], suspension: None, memos: vec![], memo_ignore: vec![], memo_notify: true, memo_limit: None, greet: String::new(), no_autoop: false, vhost: None, vhost_request: None, last_seen: ts, noexpire: false, expiry_warned: false, oper_note: None,
|
ts, home: home.into(), scram256: None, scram512: None, certfps: vec![], verified: true, ajoin: vec![], suspension: None, memos: vec![], memo_ignore: vec![], memo_notify: true, memo_limit: None, greet: String::new(), no_autoop: false, no_protect: false, vhost: None, vhost_request: None, last_seen: ts, noexpire: false, expiry_warned: false, oper_note: None,
|
||||||
};
|
};
|
||||||
let converge = |first: &Account, second: &Account| {
|
let converge = |first: &Account, second: &Account| {
|
||||||
let (mut acc, mut ch, mut gr, mut bo, mut hc, mut nd) = (HashMap::new(), HashMap::new(), HashMap::new(), HashMap::new(), HostConfig::default(), NetData::default());
|
let (mut acc, mut ch, mut gr, mut bo, mut hc, mut nd) = (HashMap::new(), HashMap::new(), HashMap::new(), HashMap::new(), HostConfig::default(), NetData::default());
|
||||||
|
|
@ -329,7 +329,7 @@
|
||||||
db.register("alice", "pw", None).unwrap();
|
db.register("alice", "pw", None).unwrap();
|
||||||
let bob = Account {
|
let bob = Account {
|
||||||
name: "bob".into(), email: None,
|
name: "bob".into(), email: None,
|
||||||
ts: 0, home: "peer".into(), scram256: None, scram512: None, certfps: vec![], verified: true, ajoin: vec![], suspension: None, memos: vec![], memo_ignore: vec![], memo_notify: true, memo_limit: None, greet: String::new(), no_autoop: false, vhost: None, vhost_request: None, last_seen: 0, noexpire: false, expiry_warned: false, oper_note: None,
|
ts: 0, home: "peer".into(), scram256: None, scram512: None, certfps: vec![], verified: true, ajoin: vec![], suspension: None, memos: vec![], memo_ignore: vec![], memo_notify: true, memo_limit: None, greet: String::new(), no_autoop: false, no_protect: false, vhost: None, vhost_request: None, last_seen: 0, noexpire: false, expiry_warned: false, oper_note: None,
|
||||||
};
|
};
|
||||||
let entry = LogEntry { origin: "peer".into(), seq: 0, lamport: 1, event: Event::AccountRegistered(Box::new(bob)) };
|
let entry = LogEntry { origin: "peer".into(), seq: 0, lamport: 1, event: Event::AccountRegistered(Box::new(bob)) };
|
||||||
db.ingest(entry).unwrap();
|
db.ingest(entry).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -579,6 +579,9 @@ impl Engine {
|
||||||
if self.network.account_of(uid) == Some(account.as_str()) {
|
if self.network.account_of(uid) == Some(account.as_str()) {
|
||||||
return Vec::new(); // already identified to it
|
return Vec::new(); // already identified to it
|
||||||
}
|
}
|
||||||
|
if !self.db.account_wants_protect(&account) {
|
||||||
|
return Vec::new(); // owner turned nick protection off (SET KILL OFF)
|
||||||
|
}
|
||||||
let Some(ns) = self.nick_service.clone() else { return Vec::new() };
|
let Some(ns) = self.nick_service.clone() else { return Vec::new() };
|
||||||
let deadline = self.now_secs() + ENFORCE_GRACE;
|
let deadline = self.now_secs() + ENFORCE_GRACE;
|
||||||
self.pending_enforce.retain(|p| p.uid != uid);
|
self.pending_enforce.retain(|p| p.uid != uid);
|
||||||
|
|
@ -1180,7 +1183,7 @@ fn audit_summary(event: &db::Event) -> Option<String> {
|
||||||
format!("{verb} channel \x02{channel}\x02 against expiry")
|
format!("{verb} channel \x02{channel}\x02 against expiry")
|
||||||
}
|
}
|
||||||
// Private, self-service, or cosmetic — not surfaced.
|
// Private, self-service, or cosmetic — not surfaced.
|
||||||
AjoinAdded { .. } | AjoinRemoved { .. } | AccountGreetSet { .. } | AccountAutoOpSet { .. } | VhostRequested { .. }
|
AjoinAdded { .. } | AjoinRemoved { .. } | AccountGreetSet { .. } | AccountAutoOpSet { .. } | AccountKillSet { .. } | VhostRequested { .. }
|
||||||
| VhostRequestCleared { .. } | MemoSent { .. } | MemoRead { .. } | MemoDeleted { .. }
|
| VhostRequestCleared { .. } | MemoSent { .. } | MemoRead { .. } | MemoDeleted { .. }
|
||||||
| MemoIgnoreAdd { .. } | MemoIgnoreDel { .. } | MemoPrefsSet { .. }
|
| MemoIgnoreAdd { .. } | MemoIgnoreDel { .. } | MemoPrefsSet { .. }
|
||||||
| ChannelMlock { .. } | ChannelDescSet { .. } | ChannelEntryMsgSet { .. } | ChannelSettingsSet { .. }
|
| ChannelMlock { .. } | ChannelDescSet { .. } | ChannelEntryMsgSet { .. } | ChannelSettingsSet { .. }
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,7 @@
|
||||||
// An earlier claim from another node wins and takes the name over.
|
// An earlier claim from another node wins and takes the name over.
|
||||||
let winner = db::Account {
|
let winner = db::Account {
|
||||||
name: "alice".into(), email: None,
|
name: "alice".into(), email: None,
|
||||||
ts: 0, home: "peer".into(), scram256: None, scram512: None, certfps: vec![], verified: true, ajoin: vec![], suspension: None, memos: vec![], memo_ignore: vec![], memo_notify: true, memo_limit: None, greet: String::new(), no_autoop: false, vhost: None, vhost_request: None, last_seen: 0, noexpire: false, expiry_warned: false, oper_note: None,
|
ts: 0, home: "peer".into(), scram256: None, scram512: None, certfps: vec![], verified: true, ajoin: vec![], suspension: None, memos: vec![], memo_ignore: vec![], memo_notify: true, memo_limit: None, greet: String::new(), no_autoop: false, no_protect: false, vhost: None, vhost_request: None, last_seen: 0, noexpire: false, expiry_warned: false, oper_note: None,
|
||||||
};
|
};
|
||||||
let entry = LogEntry::for_test("peer", 0, 1, db::Event::AccountRegistered(Box::new(winner)));
|
let entry = LogEntry::for_test("peer", 0, 1, db::Event::AccountRegistered(Box::new(winner)));
|
||||||
e.gossip_ingest(entry).unwrap();
|
e.gossip_ingest(entry).unwrap();
|
||||||
|
|
@ -666,6 +666,43 @@
|
||||||
assert!(renamed, "unidentified user on a registered nick is renamed after grace");
|
assert!(renamed, "unidentified user on a registered nick is renamed after grace");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NickServ SET KILL OFF opts an account out of nick protection: an
|
||||||
|
// unidentified user on the nick is neither prompted nor renamed.
|
||||||
|
#[test]
|
||||||
|
fn nick_protection_disabled_by_set_kill_off() {
|
||||||
|
let mut e = engine_with("nickkill", "alice", "sesame");
|
||||||
|
e.set_sid("42S".into());
|
||||||
|
e.now_override = Some(1000);
|
||||||
|
e.handle(NetEvent::EndBurst);
|
||||||
|
|
||||||
|
// Owner identifies (holding the nick) and turns protection off.
|
||||||
|
e.handle(NetEvent::UserConnect { uid: "000AAAAAA".into(), nick: "alice".into(), host: "h".into(), ip: "0.0.0.0".into() });
|
||||||
|
e.handle(NetEvent::Privmsg { from: "000AAAAAA".into(), to: "42SAAAAAA".into(), text: "IDENTIFY sesame".into() });
|
||||||
|
let out = e.handle(NetEvent::Privmsg { from: "000AAAAAA".into(), to: "42SAAAAAA".into(), text: "SET KILL OFF".into() });
|
||||||
|
assert!(out.iter().any(|a| matches!(a, NetAction::Notice { text, .. } if text.contains("off"))), "KILL OFF confirmed: {out:?}");
|
||||||
|
assert!(!e.db.account_wants_protect("alice"), "protection preference stored off");
|
||||||
|
e.handle(NetEvent::Quit { uid: "000AAAAAA".into() });
|
||||||
|
|
||||||
|
// An unidentified intruder takes the nick: no prompt, and no rename at grace.
|
||||||
|
let out = e.handle(NetEvent::UserConnect { uid: "000AAAAAB".into(), nick: "alice".into(), host: "h".into(), ip: "0.0.0.0".into() });
|
||||||
|
assert!(!out.iter().any(|a| matches!(a, NetAction::Notice { text, .. } if text.contains("registered"))), "no prompt when KILL is off: {out:?}");
|
||||||
|
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
|
||||||
|
e.set_irc_out(tx);
|
||||||
|
e.now_override = Some(1000 + ENFORCE_GRACE + 1);
|
||||||
|
e.enforce_sweep();
|
||||||
|
assert!(rx.try_recv().is_err(), "no rename when KILL is off");
|
||||||
|
|
||||||
|
// Turning it back on restores enforcement for the next arrival.
|
||||||
|
e.handle(NetEvent::Quit { uid: "000AAAAAB".into() });
|
||||||
|
e.handle(NetEvent::UserConnect { uid: "000AAAAAA".into(), nick: "alice".into(), host: "h".into(), ip: "0.0.0.0".into() });
|
||||||
|
e.handle(NetEvent::Privmsg { from: "000AAAAAA".into(), to: "42SAAAAAA".into(), text: "IDENTIFY sesame".into() });
|
||||||
|
e.handle(NetEvent::Privmsg { from: "000AAAAAA".into(), to: "42SAAAAAA".into(), text: "SET KILL ON".into() });
|
||||||
|
assert!(e.db.account_wants_protect("alice"), "protection preference stored on");
|
||||||
|
e.handle(NetEvent::Quit { uid: "000AAAAAA".into() });
|
||||||
|
let out = e.handle(NetEvent::UserConnect { uid: "000AAAAAC".into(), nick: "alice".into(), host: "h".into(), ip: "0.0.0.0".into() });
|
||||||
|
assert!(out.iter().any(|a| matches!(a, NetAction::Notice { text, .. } if text.contains("registered"))), "prompt returns when KILL back on: {out:?}");
|
||||||
|
}
|
||||||
|
|
||||||
// Identifying before the grace period cancels the pending rename.
|
// Identifying before the grace period cancels the pending rename.
|
||||||
#[test]
|
#[test]
|
||||||
fn nick_protection_cancelled_by_identify() {
|
fn nick_protection_cancelled_by_identify() {
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,7 @@ fn to_wire(entry: &LogEntry) -> Option<ReplicationEvent> {
|
||||||
| Event::AccountPasswordSet { .. }
|
| Event::AccountPasswordSet { .. }
|
||||||
| Event::AccountGreetSet { .. }
|
| Event::AccountGreetSet { .. }
|
||||||
| Event::AccountAutoOpSet { .. }
|
| Event::AccountAutoOpSet { .. }
|
||||||
|
| Event::AccountKillSet { .. }
|
||||||
| Event::AjoinAdded { .. }
|
| Event::AjoinAdded { .. }
|
||||||
| Event::AjoinRemoved { .. }
|
| Event::AjoinRemoved { .. }
|
||||||
| Event::VhostSet { .. }
|
| Event::VhostSet { .. }
|
||||||
|
|
@ -462,7 +463,7 @@ mod tests {
|
||||||
memo_ignore: vec![],
|
memo_ignore: vec![],
|
||||||
memo_notify: true,
|
memo_notify: true,
|
||||||
memo_limit: None,
|
memo_limit: None,
|
||||||
greet: String::new(), no_autoop: false,
|
greet: String::new(), no_autoop: false, no_protect: false,
|
||||||
vhost: None,
|
vhost: None,
|
||||||
vhost_request: None,
|
vhost_request: None,
|
||||||
last_seen: 111,
|
last_seen: 111,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue