snoop: gate the per-connect/join/quit eprintln! behind snoop_stderr (default off) — it wrote to stderr (journald) on every client event in the reactor thread, unbounded under a connect flood; the +c/+q snotices already carry the operator-facing signal

This commit is contained in:
Jean Chevronnet 2026-08-19 01:18:58 +00:00
parent 924141683c
commit a7f6c264d1

View file

@ -17,15 +17,19 @@ impl Module for Snoop {
.get(&uid) .get(&uid)
.map(|u| (u.nick.clone(), u.ident.clone(), u.host.clone())); .map(|u| (u.nick.clone(), u.ident.clone(), u.host.clone()));
if let Some((nick, ident, host)) = info { if let Some((nick, ident, host)) = info {
if srv.conf_bool("snoop_stderr", false) {
eprintln!("[snoop] connect {nick} ({ident}@{host})"); eprintln!("[snoop] connect {nick} ({ident}@{host})");
}
srv.snotice_c('c', &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) { fn on_join(&mut self, srv: &mut Server, uid: Uid, chan: &str) {
if srv.conf_bool("snoop_stderr", false) {
if let Some(u) = srv.users.get(&uid) { if let Some(u) = srv.users.get(&uid) {
eprintln!("[snoop] {} joined {chan}", u.nick); eprintln!("[snoop] {} joined {chan}", u.nick);
} }
} }
}
fn on_user_quit(&mut self, srv: &mut Server, uid: Uid, reason: &str) { fn on_user_quit(&mut self, srv: &mut Server, uid: Uid, reason: &str) {
// Only announce clients that actually registered. A health/liveness probe — or // Only announce clients that actually registered. A health/liveness probe — or
// any client that drops mid-handshake — never fired a connect notice, so it must // any client that drops mid-handshake — never fired a connect notice, so it must
@ -40,7 +44,9 @@ impl Module for Snoop {
else { else {
return; return;
}; };
if srv.conf_bool("snoop_stderr", false) {
eprintln!("[snoop] quit uid={uid} ({reason})"); eprintln!("[snoop] quit uid={uid} ({reason})");
}
srv.snotice_c('q', &format!("Client exiting: {nick} ({reason})")); srv.snotice_c('q', &format!("Client exiting: {nick} ({reason})"));
} }
} }