From 617d3c79661f42a0782721f181bdeafc784470d7 Mon Sep 17 00:00:00 2001 From: Jean Date: Sat, 18 Jul 2026 17:50:32 +0000 Subject: [PATCH] operserv: NOTIFY feed uses labelled fields (IP/DNS/Account/Server) and Service:verb --- src/engine/dispatch.rs | 14 +++++++------- src/engine/mod.rs | 8 ++++---- src/engine/tests.rs | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/engine/dispatch.rs b/src/engine/dispatch.rs index 1ffd21f..afb0113 100644 --- a/src/engine/dispatch.rs +++ b/src/engine/dispatch.rs @@ -75,19 +75,19 @@ impl Engine { if to.eq_ignore_ascii_case(svc.uid()) || to.eq_ignore_ascii_case(svc.nick()) { let args: Vec<&str> = text.split_whitespace().collect(); 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; } } } 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 - // the arguments, which may carry a password). SET commands carry the - // 'S' flag, everything else 's'. - let verb = text.split_whitespace().next().unwrap_or("").to_ascii_uppercase(); - let flag = if verb == "SET" { 'S' } else { 's' }; - if let Some(line) = self.notify_line(flag, from, None, &format!("used {nick} {verb}")) { + // the arguments, which may carry a password), as "Service:verb". A + // SET command carries the 'S' flag, everything else 's'. + let verb = text.split_whitespace().next().unwrap_or("").to_ascii_lowercase(); + let flag = if verb == "set" { 'S' } else { 's' }; + if let Some(line) = self.notify_line(flag, from, None, &format!("used {nick}:{verb}")) { ctx.actions.push(line); } } diff --git a/src/engine/mod.rs b/src/engine/mod.rs index cc47e23..a36275d 100644 --- a/src/engine/mod.rs +++ b/src/engine/mod.rs @@ -397,17 +397,17 @@ impl Engine { // it still correlates with what ordinary users see. let mut parts: Vec = Vec::new(); 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 { - s.push_str(&format!(" ({})", target.realhost)); + s.push_str(&format!(" DNS: {}", target.realhost)); } parts.push(s); } 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() { - 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 who = format!("\x02{}\x02!{}@{}", target.nick, target.ident, target.host); diff --git a/src/engine/tests.rs b/src/engine/tests.rs index b10a37b..37598d0 100644 --- a/src/engine/tests.rs +++ b/src/engine/tests.rs @@ -5415,8 +5415,8 @@ fn notify_hook_emits_feed_for_watched_user() { assert!( out.iter().any(|a| matches!(a, NetAction::Privmsg { from, to, text } 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 - "expected a NOTIFY connect line with the real IP, got {out:?}" + && 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 a labelled real IP, got {out:?}" ); // A clean user draws nothing. e.handle(NetEvent::UserConnect { uid: "000AAAAAD".into(), nick: "nice".into(), host: "h".into(), ip: "9.9.9.9".into() });