keepsimple1 / mdns-sd

Rust library for mDNS based Service Discovery
Apache License 2.0
104 stars 39 forks source link

add NSEC record to debug resolve issue #183

Closed keepsimple1 closed 8 months ago

keepsimple1 commented 8 months ago

This patch is to help debugging issue #182 .

Testing with this patch, it shows that python zeroconf publishes a DNS RR NSEC record (type 47) that indicates the absence of address records:

[2024-03-18T05:21:14Z DEBUG mdns_sd::dns_parser] DnsNSec { record: DnsRecord { entry: DnsEntry { name: "worky-station._workstation._tcp.local.", ty: 47, class: 1, unique: true }, ttl: 120, created: 1710739274570, expires: 1710739394570, refresh: 1710739370570 }, next_domain: "worky-station._workstation._tcp.local.", bitmap: [64, 0, 0, 8] }

The bitmap has 2 bits set: bit 1 (TYPE_A) and bit 28 (TYPE_AAAA) for Ipv4 and Ipv6 address records absence. This is the reason why the current mdns-sd lib cannot resolve its addresses.

(This patch added logging facility so that we can do this: $ RUST_LOG=debug cargo run --example query _workstation._tcp )

UPDATE: added logic to lookup for addresses if the responder provides NSEC record announcing lack of address info.

UPDATE: keep the DnsNSec record definition for future use. Also added a simple test case.