stats: oper-gate the sensitive letters, add e/q/shun x-lines and l (links)
This commit is contained in:
parent
f5cc12e809
commit
cb2ac3de81
2 changed files with 29 additions and 2 deletions
|
|
@ -213,6 +213,20 @@ impl Command for Stats {
|
||||||
}
|
}
|
||||||
fn handle(&self, s: &mut Server, uid: Uid, params: &[String]) -> CmdResult {
|
fn handle(&self, s: &mut Server, uid: Uid, params: &[String]) -> CmdResult {
|
||||||
let letter = params[0].chars().next().unwrap_or(' ');
|
let letter = params[0].chars().next().unwrap_or(' ');
|
||||||
|
// everything but uptime exposes server internals — opers only
|
||||||
|
if letter != 'u' && !s.is_oper(uid) {
|
||||||
|
s.numeric(
|
||||||
|
uid,
|
||||||
|
ERR_NOPRIVILEGES,
|
||||||
|
":Permission Denied- You're not an IRC operator",
|
||||||
|
);
|
||||||
|
s.numeric(
|
||||||
|
uid,
|
||||||
|
RPL_ENDOFSTATS,
|
||||||
|
&format!("{letter} :End of /STATS report"),
|
||||||
|
);
|
||||||
|
return CmdResult::Fail;
|
||||||
|
}
|
||||||
match letter {
|
match letter {
|
||||||
'u' => {
|
'u' => {
|
||||||
let up = now().saturating_sub(s.created);
|
let up = now().saturating_sub(s.created);
|
||||||
|
|
@ -229,11 +243,14 @@ impl Command for Stats {
|
||||||
s.numeric(uid, RPL_STATSOLINE, &format!("O * * {n} :oper"));
|
s.numeric(uid, RPL_STATSOLINE, &format!("O * * {n} :oper"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'k' | 'g' | 'z' => {
|
'k' | 'g' | 'z' | 'e' | 'q' | 's' => {
|
||||||
let kind = match letter {
|
let kind = match letter {
|
||||||
'k' => XKind::Kline,
|
'k' => XKind::Kline,
|
||||||
'g' => XKind::Gline,
|
'g' => XKind::Gline,
|
||||||
_ => XKind::Zline,
|
'z' => XKind::Zline,
|
||||||
|
'e' => XKind::Eline,
|
||||||
|
'q' => XKind::Qline,
|
||||||
|
_ => XKind::Shun,
|
||||||
};
|
};
|
||||||
let rows: Vec<String> = s
|
let rows: Vec<String> = s
|
||||||
.xlines
|
.xlines
|
||||||
|
|
@ -254,6 +271,15 @@ impl Command for Stats {
|
||||||
s.numeric(uid, RPL_STATSXLINE, &r);
|
s.numeric(uid, RPL_STATSXLINE, &r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
'l' => {
|
||||||
|
for sv in s.servers.values() {
|
||||||
|
s.numeric(
|
||||||
|
uid,
|
||||||
|
RPL_STATSLINKINFO,
|
||||||
|
&format!("{} 0 0 0 0 :{}", sv.name, sv.desc),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
s.numeric(
|
s.numeric(
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
pub const RPL_MAP: u16 = 6;
|
pub const RPL_MAP: u16 = 6;
|
||||||
pub const RPL_MAPEND: u16 = 7;
|
pub const RPL_MAPEND: u16 = 7;
|
||||||
|
pub const RPL_STATSLINKINFO: u16 = 211; // STATS l — a server link
|
||||||
pub const RPL_STATSCOMMANDS: u16 = 212;
|
pub const RPL_STATSCOMMANDS: u16 = 212;
|
||||||
pub const RPL_ENDOFSTATS: u16 = 219;
|
pub const RPL_ENDOFSTATS: u16 = 219;
|
||||||
pub const RPL_STATSUPTIME: u16 = 242;
|
pub const RPL_STATSUPTIME: u16 = 242;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue