x-lines: eline (ban exempt), shun (drop commands), qline (reserved nicks)

This commit is contained in:
Jean Chevronnet 2026-08-08 20:16:05 +00:00
parent b994faa0e7
commit cc3240c04f
4 changed files with 139 additions and 13 deletions

View file

@ -31,6 +31,9 @@ pub fn commands() -> Vec<Box<dyn Command>> {
Box::new(Kline),
Box::new(Gline),
Box::new(Zline),
Box::new(Eline),
Box::new(Shun),
Box::new(Qline),
Box::new(ChgHost),
Box::new(ChgIdent),
Box::new(SetHost),
@ -626,6 +629,48 @@ impl Command for Zline {
}
}
/// ELINE — exempt a `user@host` / ip glob from all K/G/Z-lines.
struct Eline;
impl Command for Eline {
fn name(&self) -> &'static str {
"ELINE"
}
fn min_params(&self) -> usize {
1
}
fn handle(&self, s: &mut Server, uid: Uid, params: &[String]) -> CmdResult {
do_xline(s, uid, params, XKind::Eline)
}
}
/// SHUN — let a `user@host` connect but silently drop their commands.
struct Shun;
impl Command for Shun {
fn name(&self) -> &'static str {
"SHUN"
}
fn min_params(&self) -> usize {
1
}
fn handle(&self, s: &mut Server, uid: Uid, params: &[String]) -> CmdResult {
do_xline(s, uid, params, XKind::Shun)
}
}
/// QLINE — reserve/forbid a nick glob (opers bypass it).
struct Qline;
impl Command for Qline {
fn name(&self) -> &'static str {
"QLINE"
}
fn min_params(&self) -> usize {
1
}
fn handle(&self, s: &mut Server, uid: Uid, params: &[String]) -> CmdResult {
do_xline(s, uid, params, XKind::Qline)
}
}
/// Resolve a nick to a uid, sending ERR_NOSUCHNICK if it's unknown.
fn oper_target(s: &mut Server, uid: Uid, nick: &str) -> Option<Uid> {
match s.find_nick(nick) {

View file

@ -350,6 +350,17 @@ impl Command for Nick {
);
return CmdResult::Fail;
}
// Q-line: a reserved nick is refused (opers and services bypass)
if !s.is_oper(uid) {
if let Some(reason) = s.matched_qline(newnick) {
s.numeric(
uid,
ERR_ERRONEUSNICKNAME,
&format!("{newnick} :Nickname is reserved: {reason}"),
);
return CmdResult::Fail;
}
}
if let Some(other) = s.find_nick(newnick) {
if other != uid {
s.numeric(