homebridge / ciao

RFC 6762 and RFC 6763 compliant mdns service discovery library written in Typescript
MIT License
79 stars 6 forks source link

Add support for publishing on IPv6 networks #19

Closed adriancable closed 3 weeks ago

adriancable commented 2 years ago

:recycle: Current situation

Ciao, while it can publish AAAA records over IPv4, cannot publish any records at all over IPv6. This means that on IPv6-only networks, or people who are using routers with broken IPv4 multicast support (Arris and CenturyLink - I am talking about you!), Ciao does not work. 'No Response'!

:bulb: Proposed solution

I recently made a PR for HAP-NodeJS which adds Avahi/D-Bus as a new advertiser. This supports IPv6 and generally I would recommend it. But some platforms don't/can't have Avahi, e.g. macOS and Windows. So there's still a hole.

So here is a PR to bridge that gap, and add IPv6 publishing to Ciao (which otherwise is pretty complete).

:gear: Release Notes

MDNSServer.options now adds a new advertiseIpv6 option. It defaults to false, but if you set it to true it'll publish over IPv6.

Testing

Not done much, but I have tested these things on macOS and Linux, and they at least superficially work: (adding, deleting, updating records)

I made the decision to implement IPv6 support by effectively creating "wrapper interfaces" around IPv6-capable network interfaces, which then get special treatment to handle IPv6 vs. IPv4 differences. Out of all possible approaches this keeps the largest proportion of the existing Ciao code intact, which I felt was important because it is very easy with mDNS to subtly break things. (I don't promise I haven't already done that, unfortunately.)

For completeness, it is probably worth adding equivalents to Avahi's publish-aaaa-on-ipv4 and publish-a-on-ipv6 options.

coveralls commented 2 years ago

Pull Request Test Coverage Report for Build 9588896269

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Responder.ts 0 12 0.0%
src/MDNSServer.ts 0 61 0.0%
<!-- Total: 0 73 0.0% -->
Files with Coverage Reduction New Missed Lines %
src/Responder.ts 1 0.0%
src/MDNSServer.ts 5 6.92%
<!-- Total: 6 -->
Totals Coverage Status
Change from base Build 9588870648: -0.7%
Covered Lines: 1200
Relevant Lines: 3086

💛 - Coveralls
california444 commented 6 months ago

HI, are there any plans to merge this PR to support IPv6 for ciao in the near future? Thanks!

donavanbecker commented 3 weeks ago

going to merge into the beta branch for now.