diff --git a/CHANGELOG.md b/CHANGELOG.md index 1425446..1a2a15d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added +- Add configuration variable to set Librespot AP port + ### Fixed - All requests are correctly proxied when the relevant environment variables are set diff --git a/doc/users.md b/doc/users.md index 5e45362..e2a5c1b 100644 --- a/doc/users.md +++ b/doc/users.md @@ -266,6 +266,7 @@ Possible configuration values are: | `[notification_format]` | Set the text displayed in notifications[4] | See [notification formatting](#notification-formatting) | | | `[theme]` | Custom theme | See [custom theme](#theming) | | | `[keybindings]` | Custom keybindings | See [custom keybindings](#custom-keybindings) | | +| `ap-port` | Set ap-port for librespot (for restrictive firewalls) | `80`, `443`, `4070` | | 1. If built with the `cover` feature. 2. By default the statusbar will show a play icon when a track is playing and diff --git a/src/authentication.rs b/src/authentication.rs index 34ee144..4f86d3c 100644 --- a/src/authentication.rs +++ b/src/authentication.rs @@ -45,7 +45,7 @@ pub fn get_credentials(configuration: &Config) -> Result>, pub hide_display_names: Option, pub credentials: Option, + pub ap_port: Option, } /// Commands used to obtain user credentials automatically. diff --git a/src/spotify.rs b/src/spotify.rs index fab2da4..df4fbfb 100644 --- a/src/spotify.rs +++ b/src/spotify.rs @@ -128,7 +128,7 @@ impl Spotify { } /// Generate the librespot [SessionConfig] used when creating a [Session]. - pub fn session_config() -> SessionConfig { + pub fn session_config(cfg: &config::Config) -> SessionConfig { let mut session_config = SessionConfig::default(); match env::var("http_proxy") { Ok(proxy) => { @@ -137,12 +137,18 @@ impl Spotify { } Err(_) => debug!("No HTTP proxy set"), } + if let Some(ap_port) = cfg.values().ap_port { + session_config.ap_port = Some(ap_port) + } session_config } /// Test whether `credentials` are valid Spotify credentials. - pub fn test_credentials(credentials: Credentials) -> Result { - let config = Self::session_config(); + pub fn test_credentials( + cfg: &config::Config, + credentials: Credentials, + ) -> Result { + let config = Self::session_config(cfg); ASYNC_RUNTIME .get() .unwrap() @@ -172,7 +178,7 @@ impl Spotify { ) .expect("Could not create cache"); debug!("opening spotify session"); - let session_config = Self::session_config(); + let session_config = Self::session_config(cfg); Session::connect(session_config, credentials, Some(cache), true) .await .map(|r| r.0)