Skip to content

Commit 94d174c

Browse files
authored
Discovery: Refactor and add Avahi DBus backend (#1347)
* discovery: use opaque error type for DnsSdError This helps to decouple discovery and core by not leaking implementation details of the zeroconf backend into Error conversion impls in core. * discovery: map all MDNS/DNS-SD errors to DiscoveryError::DnsSdError previously, libmdns errors would use a generic conversion from std::io::Error to core::Error * discovery: use an opaque type for the handle to the DNS-SD service * discovery: make features additive i.e. add with-libmdns instead of using not(with-dns-sd). The logic is such that enabling with-dns-sd in addition to the default with-libmdns will still end up using dns-sd, as before. If only with-libmdns is enabled, that will be the default. If none of the features is enabled, attempting to build a `Discovery` will yield an error. * discovery: add --zeroconf-backend CLI flag * discovery: Add minimal Avahi zeroconf backend * bump MSRV to 1.75 required by zbus >= 4 * discovery: ensure that server and dns-sd backend shutdown gracefully Previously, on drop the the shutdown_tx/close_tx, it wasn't guaranteed the corresponding tasks would continue to be polled until they actually completed their shutdown. Since dns_sd::Service is not Send and non-async, and because libmdns is non-async, put them on their own threads. * discovery: use a shared channel for server and zeroconf status messages * discovery: add Avahi reconnection logic This deals gracefully with the case where the Avahi daemon is restarted or not running initially. * discovery: allow running when compiled without zeroconf backend... ...but exit with an error if there's no way to authenticate * better error messages for invalid options with no short flag
1 parent d2324dd commit 94d174c

15 files changed

Lines changed: 1156 additions & 129 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1
22
ARG debian_version=slim-bookworm
3-
ARG rust_version=1.74.0
3+
ARG rust_version=1.75.0
44
FROM rust:${rust_version}-${debian_version}
55

66
ARG DEBIAN_FRONTEND=noninteractive

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
matrix:
110110
os: [ubuntu-latest]
111111
toolchain:
112-
- "1.74" # MSRV (Minimum supported rust version)
112+
- "1.75" # MSRV (Minimum supported rust version)
113113
- stable
114114
experimental: [false]
115115
# Ignore failures in beta
@@ -164,7 +164,7 @@ jobs:
164164
matrix:
165165
os: [windows-latest]
166166
toolchain:
167-
- "1.74" # MSRV (Minimum supported rust version)
167+
- "1.75" # MSRV (Minimum supported rust version)
168168
- stable
169169
steps:
170170
- name: Checkout code
@@ -215,7 +215,7 @@ jobs:
215215
- aarch64-unknown-linux-gnu
216216
- riscv64gc-unknown-linux-gnu
217217
toolchain:
218-
- "1.74" # MSRV (Minimum supported rust version)
218+
- "1.75" # MSRV (Minimum supported rust version)
219219
- stable
220220
steps:
221221
- name: Checkout code

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111

1212
- [core] The `access_token` for http requests is now acquired by `login5`
13+
- [core] MSRV is now 1.75 (breaking)
14+
- [discovery] librespot can now be compiled with multiple MDNS/DNS-SD backends
15+
(avahi, dns_sd, libmdns) which can be selected using a CLI flag. The defaults
16+
are unchanged (breaking).
1317

1418
### Added
1519

1620
- [core] Add `login` (mobile) and `auth_token` retrieval via login5
1721
- [core] Add `OS` and `os_version` to `config.rs`
22+
- [discovery] Added a new MDNS/DNS-SD backend which connects to Avahi via D-Bus.
1823

1924
### Removed
2025

COMPILING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ On Fedora systems:
5656
sudo dnf install alsa-lib-devel
5757
```
5858

59+
### Zeroconf library dependencies
60+
Depending on the chosen backend, specific development libraries are required.
61+
62+
*_Note this is an non-exhaustive list, open a PR to add to it!_*
63+
64+
| Zeroconf backend | Debian/Ubuntu | Fedora | macOS |
65+
|--------------------|------------------------------|-----------------------------------|-------------|
66+
|avahi | | | |
67+
|dns_sd | `libavahi-compat-libdnssd-dev pkg-config` | `avahi-compat-libdns_sd-devel` | |
68+
|libmdns (default) | | | |
69+
5970
### Getting the Source
6071

6172
The recommended method is to first fork the repo, so that you have a copy that you have read/write access to. After that, it’s a simple case of cloning your fork.

0 commit comments

Comments
 (0)