From 14ff36e17f24081e2add52bcc78acdb2ce2422a8 Mon Sep 17 00:00:00 2001 From: hrzlgnm Date: Thu, 22 Jan 2026 00:16:31 +0100 Subject: [PATCH] fix: only add a scope to unicast link local v6 addresses --- src/dns_parser.rs | 3 ++- src/service_info.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dns_parser.rs b/src/dns_parser.rs index 617c1000..7895751b 100644 --- a/src/dns_parser.rs +++ b/src/dns_parser.rs @@ -8,6 +8,7 @@ use crate::log::trace; use crate::error::{e_fmt, Error, Result}; +use crate::service_info::is_unicast_link_local; use if_addrs::Interface; @@ -143,7 +144,7 @@ impl fmt::Display for ScopedIp { match self { ScopedIp::V4(v4) => write!(f, "{}", v4.addr), ScopedIp::V6(v6) => { - if v6.scope_id.index != 0 { + if v6.scope_id.index != 0 && is_unicast_link_local(&v6.addr) { #[cfg(windows)] { write!(f, "{}%{}", v6.addr, v6.scope_id.index) diff --git a/src/service_info.rs b/src/service_info.rs index 0273fc5f..55f4bb13 100644 --- a/src/service_info.rs +++ b/src/service_info.rs @@ -1233,7 +1233,7 @@ pub(crate) fn split_sub_domain(domain: &str) -> (&str, Option<&str>) { /// stable on the current mdns-sd Rust version (1.71.0). /// /// https://github.com/rust-lang/rust/blob/9fc6b43126469e3858e2fe86cafb4f0fd5068869/library/core/src/net/ip_addr.rs#L1684 -fn is_unicast_link_local(addr: &Ipv6Addr) -> bool { +pub(crate) fn is_unicast_link_local(addr: &Ipv6Addr) -> bool { (addr.segments()[0] & 0xffc0) == 0xfe80 }