operserv: NOTIFY feed uses labelled fields (IP/DNS/Account/Server) and Service:verb
All checks were successful
CI / check (push) Successful in 4m5s

This commit is contained in:
Jean Chevronnet 2026-07-18 17:50:32 +00:00
parent 4247df8844
commit 617d3c7966
No known key found for this signature in database
3 changed files with 13 additions and 13 deletions

View file

@ -75,19 +75,19 @@ impl Engine {
if to.eq_ignore_ascii_case(svc.uid()) || to.eq_ignore_ascii_case(svc.nick()) { if to.eq_ignore_ascii_case(svc.uid()) || to.eq_ignore_ascii_case(svc.nick()) {
let args: Vec<&str> = text.split_whitespace().collect(); let args: Vec<&str> = text.split_whitespace().collect();
svc.on_command(&sender, &args, &mut ctx, network, db); svc.on_command(&sender, &args, &mut ctx, network, db);
matched = Some(svc.nick().to_ascii_lowercase()); matched = Some(svc.nick().to_string()); // real case, for the feed line
break; break;
} }
} }
} }
if let Some(nick) = matched { if let Some(nick) = matched {
self.bump(&format!("{nick}.command")); self.bump(&format!("{}.command", nick.to_ascii_lowercase()));
// NOTIFY watch on services use: log the service + verb only (never // NOTIFY watch on services use: log the service + verb only (never
// the arguments, which may carry a password). SET commands carry the // the arguments, which may carry a password), as "Service:verb". A
// 'S' flag, everything else 's'. // SET command carries the 'S' flag, everything else 's'.
let verb = text.split_whitespace().next().unwrap_or("").to_ascii_uppercase(); let verb = text.split_whitespace().next().unwrap_or("").to_ascii_lowercase();
let flag = if verb == "SET" { 'S' } else { 's' }; let flag = if verb == "set" { 'S' } else { 's' };
if let Some(line) = self.notify_line(flag, from, None, &format!("used {nick} {verb}")) { if let Some(line) = self.notify_line(flag, from, None, &format!("used {nick}:{verb}")) {
ctx.actions.push(line); ctx.actions.push(line);
} }
} }

View file

@ -397,17 +397,17 @@ impl Engine {
// it still correlates with what ordinary users see. // it still correlates with what ordinary users see.
let mut parts: Vec<String> = Vec::new(); let mut parts: Vec<String> = Vec::new();
if !target.ip.is_empty() { if !target.ip.is_empty() {
let mut s = format!("\x02{}\x02", target.ip); let mut s = format!("IP: \x02{}\x02", target.ip);
if !target.realhost.is_empty() && target.realhost != target.ip { if !target.realhost.is_empty() && target.realhost != target.ip {
s.push_str(&format!(" ({})", target.realhost)); s.push_str(&format!(" DNS: {}", target.realhost));
} }
parts.push(s); parts.push(s);
} }
if let Some(account) = target.account { if let Some(account) = target.account {
parts.push(format!("acct \x02{account}\x02")); parts.push(format!("Account: \x02{account}\x02"));
} }
if !target.server.is_empty() { if !target.server.is_empty() {
parts.push(format!("via {}", target.server)); parts.push(format!("Server: {}", target.server));
} }
let detail = if parts.is_empty() { String::new() } else { format!(" · {}", parts.join(" · ")) }; let detail = if parts.is_empty() { String::new() } else { format!(" · {}", parts.join(" · ")) };
let who = format!("\x02{}\x02!{}@{}", target.nick, target.ident, target.host); let who = format!("\x02{}\x02!{}@{}", target.nick, target.ident, target.host);

View file

@ -5415,8 +5415,8 @@ fn notify_hook_emits_feed_for_watched_user() {
assert!( assert!(
out.iter().any(|a| matches!(a, NetAction::Privmsg { from, to, text } out.iter().any(|a| matches!(a, NetAction::Privmsg { from, to, text }
if from == "42SAAAAAO" && to == "#services" && text.contains("[NOTIFY]") && text.contains("connected") if from == "42SAAAAAO" && to == "#services" && text.contains("[NOTIFY]") && text.contains("connected")
&& text.contains("1.2.3.4"))), // the real IP is carried, not just the cloak && text.contains("IP: ") && text.contains("1.2.3.4"))), // real IP carried under a label, not just the cloak
"expected a NOTIFY connect line with the real IP, got {out:?}" "expected a NOTIFY connect line with a labelled real IP, got {out:?}"
); );
// A clean user draws nothing. // A clean user draws nothing.
e.handle(NetEvent::UserConnect { uid: "000AAAAAD".into(), nick: "nice".into(), host: "h".into(), ip: "9.9.9.9".into() }); e.handle(NetEvent::UserConnect { uid: "000AAAAAD".into(), nick: "nice".into(), host: "h".into(), ip: "9.9.9.9".into() });