Skip to content

Commit

Permalink
macOS: New implementation of service publication (#2786)
Browse files Browse the repository at this point in the history
The current implementation of service publication on macOS uses
`avahi-client`, but the majority of macOS machines do not have Avahi
installed because macOS provides a native alternative (`mDNSresponder`),
meaning that there is no reason to install Avahi.

The current implementation also attempts to load the Avahi client
libraries using `dlopen(3)`, which has a variety of restrictions on
macOS, such as only being willing to load from certain directories.
Depending on where the Avahi binaries are installed, they might not
be loadable through the current invocation of `dlopen(3)`.

Instead of using an Avahi client on macOS, it makes more sense to use
the native macOS API for publishing services via `mDNSresponder`. This
commit supplies such an implementation that uses the macOS native API.
It also has the advantage of being much simpler than the previous
implementation. Furthermore, this new implementation works on all
macOS machines, because it relies only on native APIs, rather than on
third-party software that is not commonly installed on macOS.
  • Loading branch information
cathyjf authored Jul 7, 2024
1 parent 37b60fb commit 3cc12df
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 417 deletions.
2 changes: 1 addition & 1 deletion docs/source/building/macos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ MacPorts
Install Requirements
.. code-block:: bash
sudo port install avahi cmake curl doxygen graphviz libopus miniupnpc npm9 pkgconfig python311 py311-pip
sudo port install cmake curl doxygen graphviz libopus miniupnpc npm9 pkgconfig python311 py311-pip
Homebrew
""""""""
Expand Down
3 changes: 1 addition & 2 deletions packaging/macos/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ depends_build-append port:doxygen \
port:python311 \
port:py311-pip

depends_lib port:avahi \
port:curl \
depends_lib port:curl \
port:libopus \
port:miniupnpc

Expand Down
1 change: 1 addition & 0 deletions packaging/sunshine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class @PROJECT_NAME@ < Formula
depends_on "icu4c" => :recommended

on_linux do
depends_on "avahi"
depends_on "libcap"
depends_on "libdrm"
depends_on "libnotify"
Expand Down
1 change: 0 additions & 1 deletion src/platform/linux/publish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* @file src/platform/linux/publish.cpp
* @brief Definitions for publishing services on Linux.
* @note Adapted from https://www.avahi.org/doxygen/html/client-publish-service_8c-example.html
* @todo Use a common file for this and src/platform/macos/publish.cpp
*/
#include <thread>

Expand Down
Loading

0 comments on commit 3cc12df

Please sign in to comment.