mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Update tokio
and hyper-rustls
This commit is contained in:
parent
f202f364c9
commit
5a8bd5703c
5 changed files with 124 additions and 107 deletions
171
Cargo.lock
generated
171
Cargo.lock
generated
|
@ -345,7 +345,7 @@ version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8"
|
checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"sct",
|
"sct 0.6.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -936,12 +936,12 @@ dependencies = [
|
||||||
"headers",
|
"headers",
|
||||||
"http",
|
"http",
|
||||||
"hyper",
|
"hyper",
|
||||||
"hyper-rustls",
|
"hyper-rustls 0.22.1",
|
||||||
"rustls-native-certs",
|
"rustls-native-certs 0.5.0",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls",
|
"tokio-rustls 0.22.0",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"webpki",
|
"webpki 0.21.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -954,11 +954,26 @@ dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hyper",
|
"hyper",
|
||||||
"log",
|
"log",
|
||||||
"rustls",
|
"rustls 0.19.1",
|
||||||
"rustls-native-certs",
|
"rustls-native-certs 0.5.0",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls",
|
"tokio-rustls 0.22.0",
|
||||||
"webpki",
|
"webpki 0.21.4",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hyper-rustls"
|
||||||
|
version = "0.23.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac"
|
||||||
|
dependencies = [
|
||||||
|
"http",
|
||||||
|
"hyper",
|
||||||
|
"log",
|
||||||
|
"rustls 0.20.2",
|
||||||
|
"rustls-native-certs 0.6.1",
|
||||||
|
"tokio",
|
||||||
|
"tokio-rustls 0.23.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1009,15 +1024,6 @@ dependencies = [
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "input_buffer"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413"
|
|
||||||
dependencies = [
|
|
||||||
"bytes",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "instant"
|
name = "instant"
|
||||||
version = "0.1.12"
|
version = "0.1.12"
|
||||||
|
@ -1295,7 +1301,7 @@ dependencies = [
|
||||||
"httparse",
|
"httparse",
|
||||||
"hyper",
|
"hyper",
|
||||||
"hyper-proxy",
|
"hyper-proxy",
|
||||||
"hyper-rustls",
|
"hyper-rustls 0.23.0",
|
||||||
"librespot-protocol",
|
"librespot-protocol",
|
||||||
"log",
|
"log",
|
||||||
"num",
|
"num",
|
||||||
|
@ -1310,8 +1316,6 @@ dependencies = [
|
||||||
"protobuf",
|
"protobuf",
|
||||||
"quick-xml",
|
"quick-xml",
|
||||||
"rand",
|
"rand",
|
||||||
"rustls",
|
|
||||||
"rustls-native-certs",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha-1",
|
"sha-1",
|
||||||
|
@ -1866,26 +1870,6 @@ dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pin-project"
|
|
||||||
version = "1.0.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "576bc800220cc65dac09e99e97b08b358cfab6e17078de8dc5fee223bd2d0c08"
|
|
||||||
dependencies = [
|
|
||||||
"pin-project-internal",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pin-project-internal"
|
|
||||||
version = "1.0.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-project-lite"
|
name = "pin-project-lite"
|
||||||
version = "0.2.7"
|
version = "0.2.7"
|
||||||
|
@ -2192,8 +2176,20 @@ dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"log",
|
"log",
|
||||||
"ring",
|
"ring",
|
||||||
"sct",
|
"sct 0.6.1",
|
||||||
"webpki",
|
"webpki 0.21.4",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustls"
|
||||||
|
version = "0.20.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"ring",
|
||||||
|
"sct 0.7.0",
|
||||||
|
"webpki 0.22.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2203,11 +2199,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092"
|
checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"openssl-probe",
|
"openssl-probe",
|
||||||
"rustls",
|
"rustls 0.19.1",
|
||||||
"schannel",
|
"schannel",
|
||||||
"security-framework",
|
"security-framework",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustls-native-certs"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5ca9ebdfa27d3fc180e42879037b5338ab1c040c06affd00d8338598e7800943"
|
||||||
|
dependencies = [
|
||||||
|
"openssl-probe",
|
||||||
|
"rustls-pemfile",
|
||||||
|
"schannel",
|
||||||
|
"security-framework",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustls-pemfile"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9"
|
||||||
|
dependencies = [
|
||||||
|
"base64",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.6"
|
version = "1.0.6"
|
||||||
|
@ -2249,6 +2266,16 @@ dependencies = [
|
||||||
"untrusted",
|
"untrusted",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sct"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
|
||||||
|
dependencies = [
|
||||||
|
"ring",
|
||||||
|
"untrusted",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sdl2"
|
name = "sdl2"
|
||||||
version = "0.34.5"
|
version = "0.34.5"
|
||||||
|
@ -2643,11 +2670,10 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.14.0"
|
version = "1.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "70e992e41e0d2fb9f755b37446f20900f64446ef54874f40a60c78f021ac6144"
|
checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
|
||||||
"bytes",
|
"bytes",
|
||||||
"libc",
|
"libc",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
@ -2663,9 +2689,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-macros"
|
name = "tokio-macros"
|
||||||
version = "1.6.0"
|
version = "1.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c9efc1aba077437943f7515666aa2b882dfabfbfdf89c819ea75a8d6e9eaba5e"
|
checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -2678,9 +2704,20 @@ version = "0.22.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
|
checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustls",
|
"rustls 0.19.1",
|
||||||
"tokio",
|
"tokio",
|
||||||
"webpki",
|
"webpki 0.21.4",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tokio-rustls"
|
||||||
|
version = "0.23.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b"
|
||||||
|
dependencies = [
|
||||||
|
"rustls 0.20.2",
|
||||||
|
"tokio",
|
||||||
|
"webpki 0.22.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2696,19 +2733,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-tungstenite"
|
name = "tokio-tungstenite"
|
||||||
version = "0.14.0"
|
version = "0.16.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e96bb520beab540ab664bd5a9cfeaa1fcd846fa68c830b42e2c8963071251d2"
|
checksum = "e80b39df6afcc12cdf752398ade96a6b9e99c903dfdc36e53ad10b9c366bca72"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"log",
|
"log",
|
||||||
"pin-project",
|
"rustls 0.20.2",
|
||||||
"rustls",
|
"rustls-native-certs 0.6.1",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls",
|
"tokio-rustls 0.23.2",
|
||||||
"tungstenite",
|
"tungstenite",
|
||||||
"webpki",
|
"webpki 0.22.0",
|
||||||
"webpki-roots",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2768,25 +2804,23 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tungstenite"
|
name = "tungstenite"
|
||||||
version = "0.13.0"
|
version = "0.16.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5fe8dada8c1a3aeca77d6b51a4f1314e0f4b8e438b7b1b71e3ddaca8080e4093"
|
checksum = "6ad3713a14ae247f22a728a0456a545df14acf3867f905adff84be99e23b3ad1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"bytes",
|
"bytes",
|
||||||
"http",
|
"http",
|
||||||
"httparse",
|
"httparse",
|
||||||
"input_buffer",
|
|
||||||
"log",
|
"log",
|
||||||
"rand",
|
"rand",
|
||||||
"rustls",
|
"rustls 0.20.2",
|
||||||
"sha-1",
|
"sha-1",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"url",
|
"url",
|
||||||
"utf-8",
|
"utf-8",
|
||||||
"webpki",
|
"webpki 0.22.0",
|
||||||
"webpki-roots",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2986,12 +3020,13 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webpki-roots"
|
name = "webpki"
|
||||||
version = "0.21.1"
|
version = "0.22.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940"
|
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"webpki",
|
"ring",
|
||||||
|
"untrusted",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -16,8 +16,8 @@ rand = "0.8"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
tokio = { version = "1.0", features = ["macros", "parking_lot", "sync"] }
|
tokio = { version = "1", features = ["macros", "parking_lot", "sync"] }
|
||||||
tokio-stream = "0.1.1"
|
tokio-stream = "0.1"
|
||||||
|
|
||||||
[dependencies.librespot-core]
|
[dependencies.librespot-core]
|
||||||
path = "../core"
|
path = "../core"
|
||||||
|
|
|
@ -26,8 +26,8 @@ hmac = "0.11"
|
||||||
httparse = "1.3"
|
httparse = "1.3"
|
||||||
http = "0.2"
|
http = "0.2"
|
||||||
hyper = { version = "0.14", features = ["client", "http1", "http2", "tcp"] }
|
hyper = { version = "0.14", features = ["client", "http1", "http2", "tcp"] }
|
||||||
hyper-proxy = { version = "0.9.1", default-features = false, features = ["rustls"] }
|
hyper-proxy = { version = "0.9", default-features = false, features = ["rustls"] }
|
||||||
hyper-rustls = { version = "0.22", default-features = false, features = ["native-tokio"] }
|
hyper-rustls = { version = "0.23", features = ["http2"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
num = "0.4"
|
num = "0.4"
|
||||||
num-bigint = { version = "0.4", features = ["rand"] }
|
num-bigint = { version = "0.4", features = ["rand"] }
|
||||||
|
@ -41,16 +41,14 @@ priority-queue = "1.1"
|
||||||
protobuf = "2.14.0"
|
protobuf = "2.14.0"
|
||||||
quick-xml = { version = "0.22", features = ["serialize"] }
|
quick-xml = { version = "0.22", features = ["serialize"] }
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
rustls = "0.19"
|
|
||||||
rustls-native-certs = "0.5"
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
sha-1 = "0.9"
|
sha-1 = "0.9"
|
||||||
shannon = "0.2.0"
|
shannon = "0.2.0"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
tokio = { version = "1.5", features = ["io-util", "macros", "net", "parking_lot", "rt", "sync", "time"] }
|
tokio = { version = "1", features = ["io-util", "macros", "net", "parking_lot", "rt", "sync", "time"] }
|
||||||
tokio-stream = "0.1.1"
|
tokio-stream = "0.1"
|
||||||
tokio-tungstenite = { version = "0.14", default-features = false, features = ["rustls-tls"] }
|
tokio-tungstenite = { version = "*", default-features = false, features = ["rustls-tls-native-roots"] }
|
||||||
tokio-util = { version = "0.6", features = ["codec"] }
|
tokio-util = { version = "0.6", features = ["codec"] }
|
||||||
url = "2.1"
|
url = "2.1"
|
||||||
uuid = { version = "0.8", default-features = false, features = ["v4"] }
|
uuid = { version = "0.8", default-features = false, features = ["v4"] }
|
||||||
|
|
|
@ -9,8 +9,7 @@ use hyper::{
|
||||||
Body, Client, Request, Response, StatusCode,
|
Body, Client, Request, Response, StatusCode,
|
||||||
};
|
};
|
||||||
use hyper_proxy::{Intercept, Proxy, ProxyConnector};
|
use hyper_proxy::{Intercept, Proxy, ProxyConnector};
|
||||||
use hyper_rustls::HttpsConnector;
|
use hyper_rustls::{HttpsConnector, HttpsConnectorBuilder};
|
||||||
use rustls::{ClientConfig, RootCertStore};
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -71,10 +70,11 @@ impl From<HttpClientError> for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct HttpClient {
|
pub struct HttpClient {
|
||||||
user_agent: HeaderValue,
|
user_agent: HeaderValue,
|
||||||
proxy: Option<Url>,
|
proxy: Option<Url>,
|
||||||
tls_config: ClientConfig,
|
https_connector: HttpsConnector<HttpConnector>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HttpClient {
|
impl HttpClient {
|
||||||
|
@ -99,32 +99,21 @@ impl HttpClient {
|
||||||
|
|
||||||
let user_agent = HeaderValue::from_str(user_agent_str).unwrap_or_else(|err| {
|
let user_agent = HeaderValue::from_str(user_agent_str).unwrap_or_else(|err| {
|
||||||
error!("Invalid user agent <{}>: {}", user_agent_str, err);
|
error!("Invalid user agent <{}>: {}", user_agent_str, err);
|
||||||
error!("Please report this as a bug.");
|
|
||||||
HeaderValue::from_static(FALLBACK_USER_AGENT)
|
HeaderValue::from_static(FALLBACK_USER_AGENT)
|
||||||
});
|
});
|
||||||
|
|
||||||
// configuring TLS is expensive and should be done once per process
|
// configuring TLS is expensive and should be done once per process
|
||||||
let root_store = match rustls_native_certs::load_native_certs() {
|
let https_connector = HttpsConnectorBuilder::new()
|
||||||
Ok(store) => store,
|
.with_native_roots()
|
||||||
Err((Some(store), err)) => {
|
.https_or_http()
|
||||||
warn!("Could not load all certificates: {:?}", err);
|
.enable_http1()
|
||||||
store
|
.enable_http2()
|
||||||
}
|
.build();
|
||||||
Err((None, err)) => {
|
|
||||||
error!("Cannot access native certificate store: {}", err);
|
|
||||||
error!("Continuing, but most requests will probably fail until you fix your system certificate store.");
|
|
||||||
RootCertStore::empty()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut tls_config = ClientConfig::new();
|
|
||||||
tls_config.root_store = root_store;
|
|
||||||
tls_config.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()];
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
user_agent,
|
user_agent,
|
||||||
proxy: proxy.cloned(),
|
proxy: proxy.cloned(),
|
||||||
tls_config,
|
https_connector,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,24 +143,19 @@ impl HttpClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn request_fut(&self, mut req: Request<Body>) -> Result<ResponseFuture, Error> {
|
pub fn request_fut(&self, mut req: Request<Body>) -> Result<ResponseFuture, Error> {
|
||||||
let mut http = HttpConnector::new();
|
|
||||||
http.enforce_http(false);
|
|
||||||
|
|
||||||
let https_connector = HttpsConnector::from((http, self.tls_config.clone()));
|
|
||||||
|
|
||||||
let headers_mut = req.headers_mut();
|
let headers_mut = req.headers_mut();
|
||||||
headers_mut.insert(USER_AGENT, self.user_agent.clone());
|
headers_mut.insert(USER_AGENT, self.user_agent.clone());
|
||||||
|
|
||||||
let request = if let Some(url) = &self.proxy {
|
let request = if let Some(url) = &self.proxy {
|
||||||
let proxy_uri = url.to_string().parse()?;
|
let proxy_uri = url.to_string().parse()?;
|
||||||
let proxy = Proxy::new(Intercept::All, proxy_uri);
|
let proxy = Proxy::new(Intercept::All, proxy_uri);
|
||||||
let proxy_connector = ProxyConnector::from_proxy(https_connector, proxy)?;
|
let proxy_connector = ProxyConnector::from_proxy(self.https_connector.clone(), proxy)?;
|
||||||
|
|
||||||
Client::builder().build(proxy_connector).request(req)
|
Client::builder().build(proxy_connector).request(req)
|
||||||
} else {
|
} else {
|
||||||
Client::builder()
|
Client::builder()
|
||||||
.http2_adaptive_window(true)
|
.http2_adaptive_window(true)
|
||||||
.build(https_connector)
|
.build(self.https_connector.clone())
|
||||||
.request(req)
|
.request(req)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ rand = "0.8"
|
||||||
serde_json = "1.0.25"
|
serde_json = "1.0.25"
|
||||||
sha-1 = "0.9"
|
sha-1 = "0.9"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
tokio = { version = "1.0", features = ["parking_lot", "sync", "rt"] }
|
tokio = { version = "1", features = ["parking_lot", "sync", "rt"] }
|
||||||
|
|
||||||
[dependencies.librespot-core]
|
[dependencies.librespot-core]
|
||||||
path = "../core"
|
path = "../core"
|
||||||
|
@ -32,7 +32,7 @@ version = "0.3.1"
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
tokio = { version = "1.0", features = ["macros", "parking_lot", "rt"] }
|
tokio = { version = "1", features = ["macros", "parking_lot", "rt"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
with-dns-sd = ["dns-sd", "librespot-core/with-dns-sd"]
|
with-dns-sd = ["dns-sd", "librespot-core/with-dns-sd"]
|
||||||
|
|
Loading…
Reference in a new issue