Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add systemd-resolved mDNS advertiser support #965

Merged
merged 9 commits into from
Oct 31, 2022

Conversation

elyscape
Copy link
Contributor

♻️ Current situation

Homebridge currently supports three different mDNS advertisers, two that run in-process and one that uses Avahi over D-Bus. For a while now, systemd-resolved has supported acting as an mDNS advertiser and resolver. If Homebridge is run on a system that uses systemd-resolved for mDNS, this can cause conflicts similar to homebridge/homebridge#3077.

💡 Proposed solution

systemd-resolved, like Avahi, exposes a D-Bus interface for managing mDNS services. This pull request adds a systemd-resolved mDNS advertiser that makes use of this interface. The code was heavily based on that of the Avahi advertiser.

⚙️ Release Notes

  • Added a new mDNS advertiser named resolved that uses systemd-resolved via D-Bus.

➕ Additional Information

In order for homebridge to have the permission to use this interface, a .pkla file with the following contents will need to be installed to /etc/polkit-1/localauthority/10-vendor.d/:

[Homebridge RegisterService]
Identity=unix-user:homebridge
Action=org.freedesktop.resolve1.register-service
ResultAny=yes

[Homebridge UnregisterService]
Identity=unix-user:homebridge
Action=org.freedesktop.resolve1.unregister-service
ResultAny=yes

Testing

Seems to work for me!

See: homebridge/homebridge#3224

@coveralls
Copy link

coveralls commented Sep 13, 2022

Pull Request Test Coverage Report for Build 3358831774

  • 16 of 76 (21.05%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 51.988%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/lib/Accessory.ts 5 7 71.43%
src/lib/Advertiser.ts 11 69 15.94%
Files with Coverage Reduction New Missed Lines %
src/lib/Accessory.ts 1 43.01%
Totals Coverage Status
Change from base Build 3313107827: -0.2%
Covered Lines: 5812
Relevant Lines: 10223

💛 - Coveralls

@elyscape
Copy link
Contributor Author

Dealt with conflicts from master and ESLint warning. This should be ready whenever.

Copy link
Member

@Supereg Supereg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution 🚀
Had only a few comments on certain places ☺️

You mentioned, that there is some initial setup required to set permissions for homebridge/hap-nodejs. Can we please add this to the in-code documentation so users can easily find that.
Further, can programatically detect, if we are missing the permission for systemd-resolved such that we can issue an according warning (maybe with a link to a Wiki documentation page illustration how to configure permissions)?

src/lib/Advertiser.ts Show resolved Hide resolved
src/lib/Advertiser.ts Show resolved Hide resolved
src/lib/Advertiser.ts Outdated Show resolved Hide resolved
@Supereg Supereg changed the base branch from master to beta-0.11.0 September 19, 2022 13:58
@elyscape
Copy link
Contributor Author

Can we please add this to the in-code documentation so users can easily find that.

Sure. Where should I put it?

Further, can programatically detect, if we are missing the permission for systemd-resolved such that we can issue an according warning (maybe with a link to a Wiki documentation page illustration how to configure permissions)?

If we're missing the appropriate permissions, there are a number of different errors that can occur as a result. Rather than try to figure out what they all are, how do you feel about making the error handler always issue that warning in response to failures?

@elyscape
Copy link
Contributor Author

@Supereg Any thoughts on what else I should do to get this in a mergable state?

@elyscape
Copy link
Contributor Author

Tests should work now, btw.

@donavanbecker
Copy link
Contributor

@Supereg, I have opened this Pull Request on the UI to add resolved: homebridge/homebridge-config-ui-x#1427

Supereg added a commit that referenced this pull request Nov 18, 2022
Co-authored-by: Andi <mail@anderl-bauer.de>
Shaquu added a commit to NRCHKB/node-red-contrib-homekit-bridged that referenced this pull request Nov 20, 2022
### Added

- Support for new advertiser [AVAHI](homebridge/HAP-NodeJS#918)
- Support for new advertiser [RESOLVED](homebridge/HAP-NodeJS#965)
- Added `msg.hap.reachable` parameter to get device reachable state (related to NO_RESPONSE)

### Fixed

- Accessory could not be recovered from NO_RESPONSE using single Characteristic
- Make unsupported Characteristic error more
  descriptive [#456](#456)
- FFmpeg No such file or directory [#495](#495)
- allChars: properties have spaces in names [#496](#496)
- Wait for host to return from unpublish/destroy before exiting, set published flag on destroy
- Security system with characteristics, bad behaviour [#388](#388)

### Changed

- Updated hap-nodejs to [0.9.7](https://github.com/homebridge/HAP-NodeJS/releases/tag/v0.9.7) (bug fixes)
- Updated hap-nodejs to [0.9.8](https://github.com/homebridge/HAP-NodeJS/releases/tag/v0.9.8) (bug fixes)
- Updated hap-nodejs to [0.10.0](https://github.com/homebridge/HAP-NodeJS/releases/tag/v0.10.0) (features)
- Updated hap-nodejs to [0.10.1](https://github.com/homebridge/HAP-NodeJS/releases/tag/v0.10.1) (changes)
- Updated hap-nodejs to [0.10.2](https://github.com/homebridge/HAP-NodeJS/releases/tag/v0.10.2) (bug fixes)
- Updated hap-nodejs to [0.10.3](https://github.com/homebridge/HAP-NodeJS/releases/tag/v0.10.3) (bug fixes)
- Updated hap-nodejs to [0.10.4](https://github.com/homebridge/HAP-NodeJS/releases/tag/v0.10.4) (bug fixes)
- Updated hap-nodejs to [0.11.0](https://github.com/homebridge/HAP-NodeJS/releases/tag/v0.11.0) (features and bug fixes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants