From 7bd9186e948a31e913690a73000cfeb33e3096db Mon Sep 17 00:00:00 2001 From: Roderick van Domburg Date: Thu, 28 Jul 2022 18:51:49 +0200 Subject: [PATCH] Blacklist ap-gew4 access point (#1026) --- CHANGELOG.md | 3 ++- core/src/apresolve.rs | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4ba4628..da1cfccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [playback] `pipe`: Better error handling ### Added +- [core] `apresolve`: Blacklist ap-gew4 access point that causes channel errors - [playback] `pipe`: Implement stop ### Fixed @@ -116,7 +117,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - [connect] Fix step size on volume up/down events - [connect] Fix looping back to the first track after the last track of an album or playlist -- [playback] Incorrect `PlayerConfig::default().normalisation_threshold` caused distortion when using dynamic volume normalisation downstream +- [playback] Incorrect `PlayerConfig::default().normalisation_threshold` caused distortion when using dynamic volume normalisation downstream - [playback] Fix `log` and `cubic` volume controls to be mute at zero volume - [playback] Fix `S24_3` format on big-endian systems - [playback] `alsamixer`: make `cubic` consistent between cards that report minimum volume as mute, and cards that report some dB value diff --git a/core/src/apresolve.rs b/core/src/apresolve.rs index 759577d4..f6b89aad 100644 --- a/core/src/apresolve.rs +++ b/core/src/apresolve.rs @@ -8,6 +8,7 @@ use url::Url; const APRESOLVE_ENDPOINT: &str = "http://apresolve.spotify.com:80"; const AP_FALLBACK: &str = "ap.spotify.com:443"; +const AP_BLACKLIST: [&str; 1] = ["ap-gew4.spotify.com"]; #[derive(Clone, Debug, Deserialize)] struct ApResolveData { @@ -42,8 +43,24 @@ async fn try_apresolve( let body = hyper::body::to_bytes(response.into_body()).await?; let data: ApResolveData = serde_json::from_slice(body.as_ref())?; + // filter APs that are known to cause channel errors + let aps: Vec = data + .ap_list + .into_iter() + .filter_map(|ap| { + let host = ap.parse::().ok()?.host()?.to_owned(); + if !AP_BLACKLIST.iter().any(|&blacklisted| host == blacklisted) { + Some(ap) + } else { + warn!("Ignoring blacklisted access point {}", ap); + None + } + }) + .collect(); + let ap = if ap_port.is_some() || proxy.is_some() { - data.ap_list.into_iter().find_map(|ap| { + // filter on ports if specified on the command line... + aps.into_iter().find_map(|ap| { if ap.parse::().ok()?.port()? == port { Some(ap) } else { @@ -51,9 +68,10 @@ async fn try_apresolve( } }) } else { - data.ap_list.into_iter().next() + // ...or pick the first on the list + aps.into_iter().next() } - .ok_or("empty AP List")?; + .ok_or("Unable to resolve any viable access points.")?; Ok(ap) }