Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contrib/spotifyd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
# zeroconf port need to be allowed through any active firewall.
#zeroconf_port = 1234

# The ip addresses that `spotifyd` advertises via mDNS. By default, the addresses
# of all interfaces are advertised.
#zeroconf_ip = ["192.168.0.10"]

#-------#
# AUDIO #
#-------#
Expand Down
2 changes: 2 additions & 0 deletions docs/src/configuration/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ For this to work, you need to make sure that your firewall isn't blocking the di
- `5353 UDP`: MDNS service advertisement
- A zeroconf port which uses TCP. By default, it is randomly chosen, but if you want to, you can configure it with the `--zeroconf-port` cli option / `zeroconf_port` config value.

By default, `spotifyd` advertises the addresses of all interfaces. On hosts with many of them, clients may pick one that they cannot reach, in which case you can limit the advertisement with the `--zeroconf-ip` cli option / `zeroconf_ip` config value.

If you don't want discovery, because you're using one of the methods below, you can disable it via the `--disable-discovery` cli option / `disable_discovery = true` config value.

> __Note:__ By default, the last active session will be remembered and reconnected once the service is restarted.
Expand Down
8 changes: 8 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use std::{
borrow::Cow,
convert::TryInto,
fs,
net::IpAddr,
path::{Path, PathBuf},
str::FromStr,
};
Expand Down Expand Up @@ -339,6 +340,10 @@ pub struct SharedConfigValues {
#[arg(long)]
zeroconf_port: Option<u16>,

/// The ip addresses to advertise for the Spotify Connect discovery
#[arg(long, value_name = "IP", value_delimiter = ',')]
zeroconf_ip: Option<Vec<IpAddr>>,

/// The proxy used to connect to spotify's servers
#[arg(long, value_name = "URL")]
proxy: Option<String>,
Expand Down Expand Up @@ -583,6 +588,7 @@ impl SharedConfigValues {
on_song_change_hook,
disable_discovery,
zeroconf_port,
zeroconf_ip,
proxy,
device_type,
max_cache_size,
Expand Down Expand Up @@ -634,6 +640,7 @@ pub(crate) struct SpotifydConfig {
pub(crate) shell: String,
pub(crate) discovery: bool,
pub(crate) zeroconf_port: Option<u16>,
pub(crate) zeroconf_ip: Option<Vec<IpAddr>>,
pub(crate) device_type: LSDeviceType,
#[cfg(feature = "dbus_mpris")]
pub(crate) mpris: MprisConfig,
Expand Down Expand Up @@ -757,6 +764,7 @@ pub(crate) fn get_internal_config(config: CliConfig) -> SpotifydConfig {
shell,
discovery: !config.shared_config.disable_discovery.unwrap_or(false),
zeroconf_port: config.shared_config.zeroconf_port,
zeroconf_ip: config.shared_config.zeroconf_ip,
device_type,
#[cfg(unix)]
pid,
Expand Down
2 changes: 2 additions & 0 deletions src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub(crate) fn initial_state(
let backend = config.backend.clone();

let zeroconf_port = config.zeroconf_port.unwrap_or(0);
let zeroconf_ip = config.zeroconf_ip.unwrap_or_default();

let creds = if let Some(creds) = config.oauth_cache.as_ref().and_then(|c| c.credentials()) {
info!(
Expand Down Expand Up @@ -105,6 +106,7 @@ pub(crate) fn initial_state(
.name(config.device_name.clone())
.device_type(config.device_type)
.port(zeroconf_port)
.zeroconf_ip(zeroconf_ip.clone())
.launch()
{
Ok(discovery_stream) => break Some(discovery_stream),
Expand Down