From 2d9c4824964fc55e68b5f05c7b0872879b935ccd Mon Sep 17 00:00:00 2001 From: reverse Date: Sat, 8 Aug 2026 01:09:52 +0000 Subject: [PATCH] rehash: own techy announce messages, broadcast to all users (no path leak) --- src/coremods/core_rehash.rs | 17 ++++++++++++----- src/server.rs | 11 +++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/coremods/core_rehash.rs b/src/coremods/core_rehash.rs index b915b2a..d1a5ff7 100644 --- a/src/coremods/core_rehash.rs +++ b/src/coremods/core_rehash.rs @@ -50,6 +50,12 @@ impl Command for Rehash { let path = s.conf_path.clone(); match Config::try_load(&path) { Some(fresh) => { + // echoIRCd's own announcement (not InspIRCd's) — broadcast to + // everyone connected, not just opers. + s.announce(&format!( + "admin {who} has changed the configuration of the server." + )); + s.announce(&format!("{who} is rehashing the server config file.")); s.motd = fresh.motd; s.opers = fresh.opers; s.cloak_key = fresh.cloak_key; @@ -57,21 +63,22 @@ impl Command for Rehash { s.amu = fresh.amu; s.resolve_hosts = fresh.resolve_hosts; s.use_resolved_host = fresh.use_resolved_host; + s.announce("Server configuration reloaded."); s.numeric(uid, RPL_REHASHING, &format!("{path} :Rehashing")); - s.snotice(&format!("{who} is rehashing config: {path}")); } None => { // Unreadable config — keep what's running (do NOT reset to defaults). + s.announce(&format!( + "{who} tried to reload the server configuration, but the config file \ + could not be read — no changes were made." + )); s.send( uid, format!( - ":{} NOTICE {who} :*** Cannot read {path}; keeping the running config", + ":{} NOTICE {who} :*** Could not read {path} — the running configuration was kept.", s.name ), ); - s.snotice(&format!( - "{who} tried to REHASH but {path} could not be read; config unchanged" - )); } } CmdResult::Ok diff --git a/src/server.rs b/src/server.rs index 98ed71c..6eeb322 100644 --- a/src/server.rs +++ b/src/server.rs @@ -375,6 +375,17 @@ impl Server { } } + /// Broadcast a `*** msg` server NOTICE to *every* registered local user — for + /// server-wide announcements everyone should see (e.g. a config reload). + pub fn announce(&self, msg: &str) { + for u in self.users.values() { + if u.registered && !u.nick.is_empty() { + u.out + .send(format!(":{} NOTICE {} :*** {msg}", self.name, u.nick)); + } + } + } + /// Send a line to every member of a channel, optionally skipping one uid. pub fn to_channel(&self, key: &str, line: &str, except: Option) { if let Some(ch) = self.channels.get(key) {