mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Blacklist ap-gew4 access point (#1026)
This commit is contained in:
parent
e37fe22195
commit
7bd9186e94
2 changed files with 23 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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<String> = data
|
||||
.ap_list
|
||||
.into_iter()
|
||||
.filter_map(|ap| {
|
||||
let host = ap.parse::<Uri>().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::<Uri>().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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue