snomasks: make +s a parametric snomask mode with the standard category letters (acdfgjklnoqrtuvwx), route each server notice by category, RPL_SNOMASKIS 008; opers default to all and narrow with +s -c etc.
This commit is contained in:
parent
309201d7fb
commit
546f6279e7
16 changed files with 131 additions and 29 deletions
|
|
@ -257,7 +257,7 @@ fn pick(
|
|||
if let Some(max) = c.limit {
|
||||
if class_count(s, &c.name, uid) >= max {
|
||||
if c.maxconnwarn {
|
||||
s.snotice(&format!("connect class {} is full ({max})", c.name));
|
||||
s.snotice_c('c', &format!("connect class {} is full ({max})", c.name));
|
||||
}
|
||||
continue; // full — try the next class
|
||||
}
|
||||
|
|
@ -323,7 +323,7 @@ pub fn assign(s: &mut Server, uid: Uid) -> Option<String> {
|
|||
};
|
||||
let warn = |s: &Server, why: &str| {
|
||||
if class.maxconnwarn {
|
||||
s.snotice(&format!("connect class {} refused {ip}: {why}", class.name));
|
||||
s.snotice_c('c', &format!("connect class {} refused {ip}: {why}", class.name));
|
||||
}
|
||||
};
|
||||
if let Some(max) = class.localmax {
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ pub fn on_connect(s: &mut Server, ip: IpAddr) {
|
|||
)
|
||||
.to_string();
|
||||
s.add_xline(XKind::Zline, &glob, dur, &setter, &reason);
|
||||
s.snotice(&format!(
|
||||
s.snotice_c('x', &format!(
|
||||
"Connect flooding from IP range {glob} (threshold {threshold})"
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ fn act(s: &mut Server, uid: Uid, zone: &str, reply: Ipv4Addr) {
|
|||
None => return,
|
||||
};
|
||||
let action = s.dnsbl_action.clone();
|
||||
s.snotice(&format!(
|
||||
s.snotice_c('d', &format!(
|
||||
"DNSBL: {mask} is listed on {zone} ({reply}); action={action}"
|
||||
));
|
||||
let reason = format!("{} (listed on {zone})", s.dnsbl_reason);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ impl Module for Filter {
|
|||
Some(u) => (u.prefix(), u.addr.ip().to_string()),
|
||||
None => return ModResult::Deny,
|
||||
};
|
||||
s.snotice(&format!(
|
||||
s.snotice_c('f', &format!(
|
||||
"FILTER: {mask} matched a filter (action={action}): {reason}"
|
||||
));
|
||||
match action.as_str() {
|
||||
|
|
@ -171,7 +171,7 @@ impl Command for FilterCmd {
|
|||
duration,
|
||||
reason,
|
||||
});
|
||||
s.snotice(&format!("{nick} added FILTER {pattern} (action={action})"));
|
||||
s.snotice_c('f', &format!("{nick} added FILTER {pattern} (action={action})"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ impl Command for GlobopsCmd {
|
|||
return CmdResult::Fail;
|
||||
}
|
||||
let nick = s.users.get(&uid).map(|u| u.nick.clone()).unwrap_or_default();
|
||||
s.snotice(&format!("GLOBOPS from {nick}: {}", params.join(" ")));
|
||||
s.snotice_c('g', &format!("GLOBOPS from {nick}: {}", params.join(" ")));
|
||||
CmdResult::Ok
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ impl Command for OjoinCmd {
|
|||
if s.conf_bool("ojoin_op", true) {
|
||||
crate::coremods::core_mode::svs_set_chan_modes(s, &chan, "+o", &[nick.clone()]);
|
||||
}
|
||||
s.snotice(&format!("{nick} used OJOIN to enter {chan}"));
|
||||
s.snotice_c('v', &format!("{nick} used OJOIN to enter {chan}"));
|
||||
CmdResult::Ok
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ pub fn handle(s: &mut Server, action: &str, params: &str) -> Result<String, RpcE
|
|||
std::thread::spawn(move || {
|
||||
crate::socketengine::connect_link(&addr, tx, counter, max_line)
|
||||
});
|
||||
s.snotice(&format!("RPC initiated a link to {}", b.name));
|
||||
s.snotice_c('l', &format!("RPC initiated a link to {}", b.name));
|
||||
Ok(obj(&[("result", "true".into())]))
|
||||
}
|
||||
"disconnect" => {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ impl Module for Snoop {
|
|||
.map(|u| (u.nick.clone(), u.ident.clone(), u.host.clone()));
|
||||
if let Some((nick, ident, host)) = info {
|
||||
eprintln!("[snoop] connect {nick} ({ident}@{host})");
|
||||
srv.snotice(&format!("Client connecting: {nick} ({ident}@{host})"));
|
||||
srv.snotice_c('c', &format!("Client connecting: {nick} ({ident}@{host})"));
|
||||
}
|
||||
}
|
||||
fn on_join(&mut self, srv: &mut Server, uid: Uid, chan: &str) {
|
||||
|
|
@ -30,7 +30,7 @@ impl Module for Snoop {
|
|||
let nick = srv.users.get(&uid).map(|u| u.nick.clone());
|
||||
eprintln!("[snoop] quit uid={uid} ({reason})");
|
||||
if let Some(nick) = nick {
|
||||
srv.snotice(&format!("Client exiting: {nick} ({reason})"));
|
||||
srv.snotice_c('q', &format!("Client exiting: {nick} ({reason})"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue