Skip to content

Commit a555b15

Browse files
cathyjfReenigneArcher
authored andcommitted
macOS: New implementation of service publication
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.
1 parent 37b60fb commit a555b15

File tree

5 files changed

+97
-417
lines changed

5 files changed

+97
-417
lines changed

docs/source/building/macos.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ MacPorts
1212
Install Requirements
1313
.. code-block:: bash
1414
15-
sudo port install avahi cmake curl doxygen graphviz libopus miniupnpc npm9 pkgconfig python311 py311-pip
15+
sudo port install cmake curl doxygen graphviz libopus miniupnpc npm9 pkgconfig python311 py311-pip
1616
1717
Homebrew
1818
""""""""

packaging/macos/Portfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ depends_build-append port:doxygen \
3838
port:python311 \
3939
port:py311-pip
4040

41-
depends_lib port:avahi \
42-
port:curl \
41+
depends_lib port:curl \
4342
port:libopus \
4443
port:miniupnpc
4544

packaging/sunshine.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class @PROJECT_NAME@ < Formula
3737
depends_on "icu4c" => :recommended
3838

3939
on_linux do
40+
depends_on "avahi"
4041
depends_on "libcap"
4142
depends_on "libdrm"
4243
depends_on "libnotify"

src/platform/linux/publish.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* @file src/platform/linux/publish.cpp
33
* @brief Definitions for publishing services on Linux.
44
* @note Adapted from https://www.avahi.org/doxygen/html/client-publish-service_8c-example.html
5-
* @todo Use a common file for this and src/platform/macos/publish.cpp
65
*/
76
#include <thread>
87

0 commit comments

Comments
 (0)