mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Put apresolve behind feature flag
This commit is contained in:
parent
9253be7bc9
commit
8cff10e983
6 changed files with 124 additions and 101 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1450,6 +1450,7 @@ dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
"cfg-if 1.0.0",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"error-chain",
|
"error-chain",
|
||||||
"futures",
|
"futures",
|
||||||
|
@ -1473,7 +1474,6 @@ dependencies = [
|
||||||
"shannon",
|
"shannon",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
"tower-service",
|
|
||||||
"url 1.7.2",
|
"url 1.7.2",
|
||||||
"vergen",
|
"vergen",
|
||||||
]
|
]
|
||||||
|
|
|
@ -61,6 +61,9 @@ sha-1 = "0.8"
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
apresolve = ["librespot-core/apresolve"]
|
||||||
|
apresolve-http2 = ["librespot-core/apresolve-http2"]
|
||||||
|
|
||||||
alsa-backend = ["librespot-playback/alsa-backend"]
|
alsa-backend = ["librespot-playback/alsa-backend"]
|
||||||
portaudio-backend = ["librespot-playback/portaudio-backend"]
|
portaudio-backend = ["librespot-playback/portaudio-backend"]
|
||||||
pulseaudio-backend = ["librespot-playback/pulseaudio-backend"]
|
pulseaudio-backend = ["librespot-playback/pulseaudio-backend"]
|
||||||
|
@ -75,7 +78,7 @@ with-vorbis = ["librespot-audio/with-vorbis"]
|
||||||
|
|
||||||
# with-dns-sd = ["librespot-connect/with-dns-sd"]
|
# with-dns-sd = ["librespot-connect/with-dns-sd"]
|
||||||
|
|
||||||
default = ["librespot-playback/rodio-backend"]
|
default = ["rodio-backend", "apresolve"]
|
||||||
|
|
||||||
[package.metadata.deb]
|
[package.metadata.deb]
|
||||||
maintainer = "librespot-org"
|
maintainer = "librespot-org"
|
||||||
|
|
|
@ -17,11 +17,12 @@ aes = "0.6"
|
||||||
base64 = "0.13"
|
base64 = "0.13"
|
||||||
byteorder = "1.4"
|
byteorder = "1.4"
|
||||||
bytes = "1.0"
|
bytes = "1.0"
|
||||||
|
cfg-if = "1"
|
||||||
error-chain = { version = "0.12", default-features = false }
|
error-chain = { version = "0.12", default-features = false }
|
||||||
futures = { version = "0.3", features = ["bilock", "unstable"] }
|
futures = { version = "0.3", features = ["bilock", "unstable"] }
|
||||||
hmac = "0.10"
|
hmac = "0.10"
|
||||||
httparse = "1.3"
|
httparse = "1.3"
|
||||||
hyper = { version = "0.14", features = ["client", "tcp", "http1", "http2"] }
|
hyper = { version = "0.14", optional = true, features = ["client", "tcp", "http1"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
num-bigint = "0.3"
|
num-bigint = "0.3"
|
||||||
num-integer = "0.1"
|
num-integer = "0.1"
|
||||||
|
@ -38,7 +39,6 @@ sha-1 = "0.9"
|
||||||
shannon = "0.2.0"
|
shannon = "0.2.0"
|
||||||
tokio = { version = "1.0", features = ["io-util", "rt-multi-thread"] }
|
tokio = { version = "1.0", features = ["io-util", "rt-multi-thread"] }
|
||||||
tokio-util = { version = "0.6", features = ["codec"] }
|
tokio-util = { version = "0.6", features = ["codec"] }
|
||||||
tower-service = "0.3"
|
|
||||||
url = "1.7"
|
url = "1.7"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -48,3 +48,7 @@ vergen = "3.0.4"
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "*"
|
env_logger = "*"
|
||||||
tokio = {version = "1.0", features = ["macros"] }
|
tokio = {version = "1.0", features = ["macros"] }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
apresolve = ["hyper"]
|
||||||
|
apresolve-http2 = ["apresolve", "hyper/http2"]
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
const AP_FALLBACK: &'static str = "ap.spotify.com:443";
|
const AP_FALLBACK: &'static str = "ap.spotify.com:443";
|
||||||
|
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
cfg_if! {
|
||||||
|
if #[cfg(feature = "apresolve")] {
|
||||||
const APRESOLVE_ENDPOINT: &'static str = "http://apresolve.spotify.com:80";
|
const APRESOLVE_ENDPOINT: &'static str = "http://apresolve.spotify.com:80";
|
||||||
|
|
||||||
use hyper::{Body, Client, Method, Request, Uri};
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use url::Url;
|
|
||||||
|
use hyper::{Body, Client, Method, Request, Uri};
|
||||||
|
|
||||||
use crate::proxytunnel::ProxyTunnel;
|
use crate::proxytunnel::ProxyTunnel;
|
||||||
|
|
||||||
|
@ -59,3 +64,9 @@ pub async fn apresolve_or_fallback(proxy: &Option<Url>, ap_port: &Option<u16>) -
|
||||||
AP_FALLBACK.into()
|
AP_FALLBACK.into()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pub async fn apresolve_or_fallback(_: &Option<Url>, _: &Option<u16>) -> String {
|
||||||
|
AP_FALLBACK.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
extern crate cfg_if;
|
||||||
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate pin_project_lite;
|
extern crate pin_project_lite;
|
||||||
|
|
|
@ -1,16 +1,6 @@
|
||||||
use futures::Future;
|
use std::io;
|
||||||
use hyper::Uri;
|
|
||||||
use std::{
|
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
|
||||||
io,
|
|
||||||
net::{SocketAddr, ToSocketAddrs},
|
|
||||||
pin::Pin,
|
|
||||||
task::Poll,
|
|
||||||
};
|
|
||||||
use tokio::{
|
|
||||||
io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt},
|
|
||||||
net::TcpStream,
|
|
||||||
};
|
|
||||||
use tower_service::Service;
|
|
||||||
|
|
||||||
pub async fn connect<T: AsyncRead + AsyncWrite + Unpin>(
|
pub async fn connect<T: AsyncRead + AsyncWrite + Unpin>(
|
||||||
mut proxy_connection: T,
|
mut proxy_connection: T,
|
||||||
|
@ -64,6 +54,17 @@ pub async fn connect<T: AsyncRead + AsyncWrite + Unpin>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg_if! {
|
||||||
|
if #[cfg(feature = "apresolve")] {
|
||||||
|
use std::future::Future;
|
||||||
|
use std::net::{SocketAddr, ToSocketAddrs};
|
||||||
|
use std::pin::Pin;
|
||||||
|
use std::task::Poll;
|
||||||
|
|
||||||
|
use hyper::service::Service;
|
||||||
|
use hyper::Uri;
|
||||||
|
use tokio::net::TcpStream;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ProxyTunnel {
|
pub struct ProxyTunnel {
|
||||||
proxy_addr: SocketAddr,
|
proxy_addr: SocketAddr,
|
||||||
|
@ -104,3 +105,5 @@ impl Service<Uri> for ProxyTunnel {
|
||||||
Box::pin(fut)
|
Box::pin(fut)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue