rehash: own techy announce messages, broadcast to all users (no path leak)
This commit is contained in:
parent
fceafa8064
commit
2d9c482496
2 changed files with 23 additions and 5 deletions
|
|
@ -50,6 +50,12 @@ impl Command for Rehash {
|
||||||
let path = s.conf_path.clone();
|
let path = s.conf_path.clone();
|
||||||
match Config::try_load(&path) {
|
match Config::try_load(&path) {
|
||||||
Some(fresh) => {
|
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.motd = fresh.motd;
|
||||||
s.opers = fresh.opers;
|
s.opers = fresh.opers;
|
||||||
s.cloak_key = fresh.cloak_key;
|
s.cloak_key = fresh.cloak_key;
|
||||||
|
|
@ -57,21 +63,22 @@ impl Command for Rehash {
|
||||||
s.amu = fresh.amu;
|
s.amu = fresh.amu;
|
||||||
s.resolve_hosts = fresh.resolve_hosts;
|
s.resolve_hosts = fresh.resolve_hosts;
|
||||||
s.use_resolved_host = fresh.use_resolved_host;
|
s.use_resolved_host = fresh.use_resolved_host;
|
||||||
|
s.announce("Server configuration reloaded.");
|
||||||
s.numeric(uid, RPL_REHASHING, &format!("{path} :Rehashing"));
|
s.numeric(uid, RPL_REHASHING, &format!("{path} :Rehashing"));
|
||||||
s.snotice(&format!("{who} is rehashing config: {path}"));
|
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// Unreadable config — keep what's running (do NOT reset to defaults).
|
// 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(
|
s.send(
|
||||||
uid,
|
uid,
|
||||||
format!(
|
format!(
|
||||||
":{} NOTICE {who} :*** Cannot read {path}; keeping the running config",
|
":{} NOTICE {who} :*** Could not read {path} — the running configuration was kept.",
|
||||||
s.name
|
s.name
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
s.snotice(&format!(
|
|
||||||
"{who} tried to REHASH but {path} could not be read; config unchanged"
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CmdResult::Ok
|
CmdResult::Ok
|
||||||
|
|
|
||||||
|
|
@ -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.
|
/// Send a line to every member of a channel, optionally skipping one uid.
|
||||||
pub fn to_channel(&self, key: &str, line: &str, except: Option<Uid>) {
|
pub fn to_channel(&self, key: &str, line: &str, except: Option<Uid>) {
|
||||||
if let Some(ch) = self.channels.get(key) {
|
if let Some(ch) = self.channels.get(key) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue