whois: build the target snapshot as a named WhoisInfo struct instead of a 17-field positional tuple — field-named construction can't silently transpose two same-typed fields; destructured into the same locals so the reply code is unchanged

This commit is contained in:
Jean Chevronnet 2026-08-19 01:58:01 +00:00
parent ea3e879068
commit 5101b1361d

View file

@ -180,7 +180,28 @@ impl Command for Whois {
// hidewhois: hide sensitive lines from ordinary users (opers/self exempt per config) // hidewhois: hide sensitive lines from ordinary users (opers/self exempt per config)
let hide = crate::modules::hidewhois::hide(s, uid, tuid, asker_oper); let hide = crate::modules::hidewhois::hide(s, uid, tuid, asker_oper);
let keys: Vec<String> = s.users[&tuid].channels.iter().cloned().collect(); let keys: Vec<String> = s.users[&tuid].channels.iter().cloned().collect();
let ( // A named snapshot of the target for the WHOIS reply — a struct rather than a
// 17-field positional tuple, so construction can't silently transpose fields.
struct WhoisInfo {
nick: String,
ident: String,
disp: String,
realname: String,
realhost: String,
realip: String,
secure: bool,
oper: bool,
bot: bool,
hideoper: bool,
hidechans: bool,
account: Option<String>,
last_active: u64,
signon: u64,
certfp: Option<String>,
swhois: Option<String>,
showwhois: bool,
}
let WhoisInfo {
nick, nick,
ident, ident,
disp, disp,
@ -198,29 +219,30 @@ impl Command for Whois {
certfp, certfp,
swhois, swhois,
showwhois, showwhois,
) = { } = {
let u = &s.users[&tuid]; let u = &s.users[&tuid];
( WhoisInfo {
u.nick.clone(), nick: u.nick.clone(),
u.ident.clone(), ident: u.ident.clone(),
u.host_display().to_string(), disp: u.host_display().to_string(),
u.realname.clone(), realname: u.realname.clone(),
u.host.clone(), realhost: u.host.clone(),
u.addr.ip().to_string(), realip: u.addr.ip().to_string(),
u.secure, secure: u.secure,
u.flags.oper, oper: u.flags.oper,
u.flags.bot, bot: u.flags.bot,
u.flags.hideoper, hideoper: u.flags.hideoper,
u.flags.hidechans, hidechans: u.flags.hidechans,
u.account.clone(), account: u.account.clone(),
u.last_active, last_active: u.last_active,
u.signon, signon: u.signon,
u.certfp.clone(), certfp: u.certfp.clone(),
u.ext swhois: u
.ext
.get::<crate::coremods::core_oper::Swhois>() .get::<crate::coremods::core_oper::Swhois>()
.map(|w| w.0.clone()), .map(|w| w.0.clone()),
u.flags.showwhois, showwhois: u.flags.showwhois,
) }
}; };
let chans: Vec<String> = keys let chans: Vec<String> = keys
.iter() .iter()