Expand OperServ: SQLINE nick bans, GLOBAL, and KILL
Generalise the network-ban store to carry the ircd X-line kind (defaulted to the user@host G-line for existing records) so one event-sourced, lazily-expiring, burst-reasserted list backs every ban type, and drive ADD/DEL/LIST from one implementation per kind: - AKILL stays the user@host G-line; SQLINE is a nick Q-line, its mask validated as a nick glob (an @ is refused so an AKILL-shaped mask can't become an over-broad nick ban). Both are keyed by (kind, mask). - GLOBAL <message> announces to every user via a $* server-glob notice. - KILL <nick> [reason] disconnects a user, attributed to the operator. All four are admin-gated, and OperServ itself stays invisible to non-opers. Bans and kills go out as typed actions (AddLine/DelLine/KillUser) the ircd link serialises to ADDLINE/DELLINE/KILL.
This commit is contained in:
parent
57e104e510
commit
930198b826
9 changed files with 351 additions and 189 deletions
21
operserv/src/kill.rs
Normal file
21
operserv/src/kill.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
use fedserv_api::{NetView, Priv, Sender, ServiceCtx};
|
||||
|
||||
// KILL <nick> [reason]: disconnect a user from the network. Admin-only.
|
||||
pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, net: &dyn NetView) {
|
||||
if !from.privs.has(Priv::Admin) {
|
||||
ctx.notice(me, from.uid, "Access denied — KILL needs the \x02admin\x02 privilege.");
|
||||
return;
|
||||
}
|
||||
let Some(&target) = args.get(1) else {
|
||||
ctx.notice(me, from.uid, "Syntax: KILL <nick> [reason]");
|
||||
return;
|
||||
};
|
||||
let Some(uid) = net.uid_by_nick(target).map(str::to_string) else {
|
||||
ctx.notice(me, from.uid, format!("There's no \x02{target}\x02 online."));
|
||||
return;
|
||||
};
|
||||
let by = from.account.unwrap_or(from.nick);
|
||||
let reason = if args.len() > 2 { args[2..].join(" ") } else { "No reason given".to_string() };
|
||||
ctx.kill(me, &uid, &format!("({by}) {reason}"));
|
||||
ctx.notice(me, from.uid, format!("\x02{target}\x02 has been disconnected."));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue