diff --git a/Cargo.lock b/Cargo.lock index 5813a707..3754fd69 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -962,6 +962,31 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" +[[package]] +name = "headers" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62689dc57c7456e69712607ffcbd0aa1dfcccf9af73727e9b25bc1825375cac3" +dependencies = [ + "base64 0.13.0", + "bitflags 1.2.1", + "bytes", + "headers-core", + "http", + "mime", + "sha-1", + "time 0.1.43", +] + +[[package]] +name = "headers-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +dependencies = [ + "http", +] + [[package]] name = "heck" version = "0.3.2" @@ -1047,6 +1072,20 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-proxy" +version = "0.8.0" +source = "git+https://github.com/e00E/hyper-proxy.git?branch=upgrade-tokio#4be706f2f0297bd3d14f301b6ea0be8f3078bb17" +dependencies = [ + "bytes", + "futures", + "headers", + "http", + "hyper", + "tokio", + "tower-service", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1323,6 +1362,7 @@ dependencies = [ "hmac", "httparse", "hyper", + "hyper-proxy", "librespot-protocol", "log", "num-bigint", @@ -1452,6 +1492,12 @@ version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + [[package]] name = "miniz_oxide" version = "0.4.3" diff --git a/core/Cargo.toml b/core/Cargo.toml index c092c04d..4ff46936 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -21,6 +21,7 @@ futures = { version = "0.3", features = ["bilock", "unstable"] } hmac = "0.7" httparse = "1.3" hyper = { version = "0.14", features = ["client", "tcp", "http1", "http2"] } +hyper-proxy = { git = "https://github.com/e00E/hyper-proxy.git", branch="upgrade-tokio", default_features = false } log = "0.4" num-bigint = "0.3" num-integer = "0.1" diff --git a/core/src/apresolve.rs b/core/src/apresolve.rs index 07c2958f..d35b2091 100644 --- a/core/src/apresolve.rs +++ b/core/src/apresolve.rs @@ -1,7 +1,8 @@ const AP_FALLBACK: &'static str = "ap.spotify.com:443"; const APRESOLVE_ENDPOINT: &'static str = "http://apresolve.spotify.com/"; -use hyper::{Body, Client, Method, Request, Uri}; +use hyper::{client::HttpConnector, Body, Client, Method, Request, Uri}; +use hyper_proxy::{Intercept, Proxy, ProxyConnector}; use std::error::Error; use url::Url; @@ -13,7 +14,7 @@ pub struct APResolveData { async fn apresolve(proxy: &Option, ap_port: &Option) -> Result> { let port = ap_port.unwrap_or(443); - let req = Request::builder() + let mut req = Request::builder() .method(Method::GET) .uri( APRESOLVE_ENDPOINT @@ -22,25 +23,22 @@ async fn apresolve(proxy: &Option, ap_port: &Option) -> Result, ap_port: &Option) -> Result