-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Functionality for being able to look up the IP address of a service on a dnssd system is needed. The documentation for DNSServiceRegister says that the application is responsible for using DNSServiceRegisterRecord to create an address record, otherwise it won't exist.
I sort of expected that functionality to be optionally automatically chained, because the browser does the same for DNSServiceBrowse, DNSServiceResolve, then the DNSServiceGetAddrInfo callbacks.
Possible solutions
Patching options:
- add
DNSServiceRegisterRecordas part of the service registration mechanism - resolve why the domain when set did not appear in
dns-sd -Lfor the updated example code, perhaps from item above
Other way of structuring API (same for avahi):
- pay the cost of copying the record data and break up the callback chain re-passing some of the raw pointers
- add other missing needed callback wrappers, e.g.,
DNSServiceRegisterRecord - use the wrappers to build up things like browse and service
Details
I added some extra command line args to the service example and added more tracing to debug this, e.g., added service-name parameter so I could use myservice in this example, while the other device is a soundbar:
% RUST_LOG=info cargo run --bin zeroconf-service-example -- --service-name myservice --hostname myservice --domain local
[2024-10-28T12:23:22Z INFO zeroconf_service_example] Starting loop for: BonjourMdnsService { service: Mutex { data: ManagedDNSServiceRef(0x0), poisoned: false, .. }, kind: "_http._tcp", port: 8080, name: Some("myservice"), domain: Some("local"), host: Some("myservice"), interface_index: 0, txt_record: Some(TxtRecord { data: {"foo": "bar"} }), context: BonjourServiceContext { user_context: Some(Any { .. }) } }
[2024-10-28T12:23:23Z INFO zeroconf_service_example] Service registered: ServiceRegistration { name: "myservice", service_type: ServiceType { name: "http", protocol: "tcp", sub_types: [] }, domain: "local" }
[2024-10-28T12:23:23Z INFO zeroconf_service_example] Context: Mutex { data: Context { service_name: "myservice" }, poisoned: false, .. }% dns-sd -B _http
Browsing for _http._tcp
DATE: ---Mon 28 Oct 2024---
7:23:37.741 ...STARTING...
Timestamp A/R Flags if Domain Service Type Instance Name
7:23:37.742 Add 3 11 local. _http._tcp. 9x25 MobileAP MDNS
7:23:37.742 Add 3 1 local. _http._tcp. myservice
7:23:37.742 Add 2 11 local. _http._tcp. myservice% dns-sd -L "9x25 MobileAP MDNS" _http._tcp. local.
Lookup 9x25 MobileAP MDNS._http._tcp..local.
DATE: ---Mon 28 Oct 2024---
7:26:19.239 ...STARTING...
7:26:19.535 9x25\032MobileAP\032MDNS._http._tcp.local. can be reached at Bose-[UUID REDACTED].local.:80 (interface 11)% dns-sd -Gv4v6 Bose-[UUID REDACTED].local.
DATE: ---Mon 28 Oct 2024---
7:03:23.276 ...STARTING...
Timestamp A/R Flags IF Hostname Address TTL
7:26:59.146 Add 40000003 11 Bose-[UUID REDACTED].local. [IPV6 REDACTED]%<0> 120
7:26:59.146 Add 40000002 11 Bose-[UUID REDACTED].local. [IPV4 REDACTED] 120While curiously the local. part of the domain is left off of zerfoconf-rs service example:
% dns-sd -L myservice _http._tcp. local.
Lookup myservice._http._tcp..local.
DATE: ---Mon 28 Oct 2024---
7:28:45.173 ...STARTING...
7:28:45.174 myservice._http._tcp.local. can be reached at myservice.:8080 (interface 1) Flags: 1
foo=bar
7:28:45.174 myservice._http._tcp.local. can be reached at myservice.:8080 (interface 11)
foo=barThere is no record for the IP address for myservice:
% dns-sd -Gv4v6 myservice.
DATE: ---Mon 28 Oct 2024---
7:30:02.258 ...STARTING...
Timestamp A/R Flags IF Hostname Address TTL
7:30:02.264 Add 2 0 myservice. 0000:0000:0000:0000:0000:0000:0000:0000%<0> 77 No Such Record
7:30:02.265 Add 2 0 myservice. 0.0.0.0 77 No Such RecordWhile dns-sd -L saying myservice had domain local, dns-sd -L said it didn't, so as "expected", dns-sd -Gv4v6 returns not even a null record:
% dns-sd -Gv4v6 myservice.local.
DATE: ---Mon 28 Oct 2024---
7:30:18.096 ...STARTING...