troglobit / mdnsd

Jeremie Miller's original mdnsd
BSD 3-Clause "New" or "Revised" License
56 stars 35 forks source link

The examples produce resource records that don't comply with RFC6763 #80

Open evverx opened 1 month ago

evverx commented 1 month ago

The first two examples at https://github.com/troglobit/mdnsd?tab=readme-ov-file#service-records come with

target ftp.luthien.local

and it leads to PTR resource records like

        _ftp._tcp.local: type PTR, class IN, ftp.luthien.local
            Name: _ftp._tcp.local
            Type: PTR (12) (domain name PoinTeR)
            .000 0000 0000 0001 = Class: IN (0x0001)
            0... .... .... .... = Cache flush: False
            Time to live: 120 (2 minutes)
            Data length: 14
            Domain Name: ftp.luthien.local

where _ftp._tcp.local points to ftp.luthien.local.

The problem is that avahi-browse (or any other mDNS browser) can't follow those PTR resource records so those services can't be discovered using those tools. It's still possible to resolve the services directly since their SRV and TXT resource records are advertised too but there is no link between _ftp._tcp.local and Troglobit FTP Server._ftp._tcp.local anywhere.

According to https://datatracker.ietf.org/doc/html/rfc6763#section-4.1

   The result of this PTR lookup for the name "<Service>.<Domain>" is a
   set of zero or more PTR records giving Service Instance Names of the
   form:

      Service Instance Name = <Instance> . <Service> . <Domain>

where <Service> should follow https://datatracker.ietf.org/doc/html/rfc6763#section-7

   The <Service> portion of the Service Instance Name consists of a pair
   of DNS labels, following the convention already established for SRV
   records [RFC2782].  The first label of the pair is an underscore
   character followed by the Service Name [RFC6335].  The Service Name
   identifies what the service does and what application protocol it
   uses to do it.  The second label is either "_tcp" (for application
   protocols that run over TCP) or "_udp" (for all others).
evverx commented 1 month ago

I'm not sure what to do though. It makes it possible to test things like https://github.com/avahi/avahi/commit/93b14365c1c1e04efd1a890e8caa01a2a514bfd8 so from that perspective I think it's great that it's possible to send PTR RRs like that. I'm not sure it should be included in the examples though. It could be that they are copied verbatim and end up being advertised by various devices like for example https://github.com/avahi/avahi/issues/251. Those avahi bugs were fixed so it isn't that bad anymore but still.

Looking at https://github.com/troglobit/mdnsd/blob/5346604fcdeccd99f9943ac5ef887c3880480338/man/mdnsd.service.5#L72-L73 it seems that targets should go to SRV resource records.