diff --git a/Cargo.lock b/Cargo.lock index 688b25f7..7508e925 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -998,7 +998,7 @@ dependencies = [ [[package]] name = "dragonfly-client" -version = "0.2.21" +version = "0.2.22" dependencies = [ "anyhow", "blake3", @@ -1069,7 +1069,7 @@ dependencies = [ [[package]] name = "dragonfly-client-backend" -version = "0.2.21" +version = "0.2.22" dependencies = [ "dragonfly-api", "dragonfly-client-core", @@ -1100,7 +1100,7 @@ dependencies = [ [[package]] name = "dragonfly-client-config" -version = "0.2.21" +version = "0.2.22" dependencies = [ "bytesize", "bytesize-serde", @@ -1126,7 +1126,7 @@ dependencies = [ [[package]] name = "dragonfly-client-core" -version = "0.2.21" +version = "0.2.22" dependencies = [ "headers 0.4.0", "hyper 1.6.0", @@ -1145,7 +1145,7 @@ dependencies = [ [[package]] name = "dragonfly-client-init" -version = "0.2.21" +version = "0.2.22" dependencies = [ "anyhow", "clap", @@ -1163,7 +1163,7 @@ dependencies = [ [[package]] name = "dragonfly-client-storage" -version = "0.2.21" +version = "0.2.22" dependencies = [ "base16ct", "bincode", @@ -1193,7 +1193,7 @@ dependencies = [ [[package]] name = "dragonfly-client-util" -version = "0.2.21" +version = "0.2.22" dependencies = [ "base16ct", "base64 0.22.1", @@ -1606,7 +1606,7 @@ dependencies = [ [[package]] name = "hdfs" -version = "0.2.21" +version = "0.2.22" dependencies = [ "dragonfly-client-backend", "dragonfly-client-core", diff --git a/Cargo.toml b/Cargo.toml index 0bcd672f..801aeed5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ members = [ ] [workspace.package] -version = "0.2.21" +version = "0.2.22" authors = ["The Dragonfly Developers"] homepage = "https://d7y.io/" repository = "https://github.com/dragonflyoss/client.git" @@ -22,13 +22,13 @@ readme = "README.md" edition = "2021" [workspace.dependencies] -dragonfly-client = { path = "dragonfly-client", version = "0.2.21" } -dragonfly-client-core = { path = "dragonfly-client-core", version = "0.2.21" } -dragonfly-client-config = { path = "dragonfly-client-config", version = "0.2.21" } -dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.2.21" } -dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.2.21" } -dragonfly-client-util = { path = "dragonfly-client-util", version = "0.2.21" } -dragonfly-client-init = { path = "dragonfly-client-init", version = "0.2.21" } +dragonfly-client = { path = "dragonfly-client", version = "0.2.22" } +dragonfly-client-core = { path = "dragonfly-client-core", version = "0.2.22" } +dragonfly-client-config = { path = "dragonfly-client-config", version = "0.2.22" } +dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.2.22" } +dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.2.22" } +dragonfly-client-util = { path = "dragonfly-client-util", version = "0.2.22" } +dragonfly-client-init = { path = "dragonfly-client-init", version = "0.2.22" } thiserror = "1.0" dragonfly-api = "=2.1.36" reqwest = { version = "0.12.4", features = [ diff --git a/dragonfly-client/src/proxy/mod.rs b/dragonfly-client/src/proxy/mod.rs index a1c6deaa..148dea30 100644 --- a/dragonfly-client/src/proxy/mod.rs +++ b/dragonfly-client/src/proxy/mod.rs @@ -430,6 +430,7 @@ pub async fn https_handler( // Proxy the request directly to the remote server. if let Some(host) = request.uri().host() { let host = host.to_string(); + let port = request.uri().port_u16().unwrap_or(443); tokio::task::spawn(async move { match hyper::upgrade::on(request).await { Ok(upgraded) => { @@ -438,6 +439,7 @@ pub async fn https_handler( task, upgraded, host, + port, dfdaemon_download_client, registry_cert, server_ca_cert, @@ -467,6 +469,7 @@ async fn upgraded_tunnel( task: Arc, upgraded: Upgraded, host: String, + port: u16, dfdaemon_download_client: DfdaemonDownloadClient, registry_cert: Arc>>>, server_ca_cert: Arc>, @@ -513,6 +516,7 @@ async fn upgraded_tunnel( config.clone(), task.clone(), host.clone(), + port, request, dfdaemon_download_client.clone(), registry_cert.clone(), @@ -534,6 +538,7 @@ pub async fn upgraded_handler( config: Arc, task: Arc, host: String, + port: u16, mut request: Request, dfdaemon_download_client: DfdaemonDownloadClient, registry_cert: Arc>>>, @@ -558,8 +563,18 @@ pub async fn upgraded_handler( // If the scheme is not set, set the scheme to https. if request.uri().scheme().is_none() { - *request.uri_mut() = format!("https://{}{}", host, request.uri()) - .parse() + let builder = http::uri::Builder::new(); + *request.uri_mut() = builder + .scheme("https") + .authority(format!("{}:{}", host, port)) + .path_and_query( + request + .uri() + .path_and_query() + .map(|v| v.as_str()) + .unwrap_or("/"), + ) + .build() .or_err(ErrorType::ParseError)?; }