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

Register listener on the dbus interface to detect Avahi deamon restarts #970

Merged
merged 3 commits into from
Oct 31, 2022

Conversation

Supereg
Copy link
Member

@Supereg Supereg commented Sep 17, 2022

♻️ Current situation

As of now we don't detect restarts of Avahi Deamon and therefore remain without an advertising in this situation as explained in #923.

💡 Proposed solution

This PR fixes this by subscribing on the dbus StateChanged listener to detect avahi deamon restarts.

⚙️ Release Notes

  • Properly recreate advertisements on restarts of avahi when using the avahi/dbus based advertiser.

➕ Additional Information

Testing

--

Reviewer Nudging

--

@github-actions github-actions bot added the fix label Sep 17, 2022
@Supereg
Copy link
Member Author

Supereg commented Sep 17, 2022

@adriancable I'm currently unable to test this on a live machine. Could you verify, that this works as expected?

@coveralls
Copy link

coveralls commented Sep 17, 2022

Pull Request Test Coverage Report for Build 3358922347

  • 10 of 28 (35.71%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.07%) to 51.913%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/lib/Advertiser.ts 10 28 35.71%
Files with Coverage Reduction New Missed Lines %
src/lib/Advertiser.ts 1 41.61%
Totals Coverage Status
Change from base Build 3358848225: -0.07%
Covered Lines: 5820
Relevant Lines: 10247

💛 - Coveralls

@adriancable
Copy link
Contributor

Hi @Supereg - I'm on vacation until the end of the month and don't have access to a Linux machine to test. I'll happily have a look at the start of October if you can't find anyone else to test before that. Sorry!

@Supereg
Copy link
Member Author

Supereg commented Sep 17, 2022

Well, I’m for a half a year in South Korea 😄 so let’s see, maybe I can start up one of my machines at home :) otherwise it will be October 🙃

@Supereg Supereg changed the title Register listener on the listener to detect Avahi deamon restarts Register listener on the dbus interface to detect Avahi deamon restarts Sep 19, 2022
@Supereg Supereg force-pushed the fix/avahi-server-state-handling branch from 1cd69df to 3f69ec8 Compare October 31, 2022 05:44
@Supereg Supereg requested a review from adriancable October 31, 2022 05:53
@Supereg
Copy link
Member Author

Supereg commented Oct 31, 2022

Have verified functionality (have restarted the daemon twice in the below log output). The re advertisement is also pretty fast:

DEBUG=HAP-NodeJS:Advertiser node dist/BridgedCore.js
  HAP-NodeJS:Advertiser Initializing HAP-NodeJS v0.10.4 ... +0ms
HAP-NodeJS fix/avahi-server-state-handling starting...
  HAP-NodeJS:Advertiser Detected Avahi over DBus interface running version 'avahi 0.7'. +0ms
  HAP-NodeJS:Advertiser Preparing Advertiser for 'Node Bridge 5BA5' using Avahi backend! +1ms
  HAP-NodeJS:Advertiser Starting to advertise 'Node Bridge 5BA5' using Avahi backend! +0ms
  HAP-NodeJS:Advertiser Found Avahi daemon to have restarted! +21s
  HAP-NodeJS:Advertiser Starting to advertise 'Node Bridge 5BA5' using Avahi backend! +0ms
  HAP-NodeJS:Advertiser Found Avahi daemon to have restarted! +15s
  HAP-NodeJS:Advertiser Starting to advertise 'Node Bridge 5BA5' using Avahi backend! +1ms

Calling avahi-browse afterwards yields positive results:

avahi-browse _hap._tcp --resolve
+ enp0s1 IPv6 Node Bridge 5BA5                              _hap._tcp            local
+ enp0s1 IPv4 Node Bridge 5BA5                              _hap._tcp            local
+     lo IPv4 Node Bridge 5BA5                              _hap._tcp            local
= enp0s1 IPv6 Node Bridge 5BA5                              _hap._tcp            local
   hostname = [primary.local]
   address = [fdfa:e7fa:e3cd:3065:5054:ff:febe:4642]
   port = [51826]
   txt = ["sh=73Llyg==" "ci=2" "sf=1" "s#=1" "pv=1.1" "md=Default-Model" "id=CC:22:3D:E3:CE:F6" "ff=0" "c#=3"]
= enp0s1 IPv4 Node Bridge 5BA5                              _hap._tcp            local
   hostname = [primary.local]
   address = [192.168.64.2]
   port = [51826]
   txt = ["sh=73Llyg==" "ci=2" "sf=1" "s#=1" "pv=1.1" "md=Default-Model" "id=CC:22:3D:E3:CE:F6" "ff=0" "c#=3"]
=     lo IPv4 Node Bridge 5BA5                              _hap._tcp            local
   hostname = [primary.local]
   address = [127.0.0.1]
   port = [51826]
   txt = ["sh=73Llyg==" "ci=2" "sf=1" "s#=1" "pv=1.1" "md=Default-Model" "id=CC:22:3D:E3:CE:F6" "ff=0" "c#=3"]

@Supereg Supereg merged commit 27778bd into beta-0.11.0 Oct 31, 2022
@Supereg Supereg deleted the fix/avahi-server-state-handling branch October 31, 2022 06:40
Supereg added a commit that referenced this pull request Nov 18, 2022
…ts (#970)

* Register listener on the listener to detect Avahi deamon restarts

* Add comment about systemd-resolved feature state.
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.

3 participants