Skip to content

Commit aa2a6c8

Browse files
authored
feat: bump version to 1.1.18 and fix host header for non-standard HTTPS ports (#1592)
Signed-off-by: Gaius <gaius.qi@gmail.com>
1 parent 4b38782 commit aa2a6c8

File tree

3 files changed

+45
-21
lines changed

3 files changed

+45
-21
lines changed

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ members = [
1313
]
1414

1515
[workspace.package]
16-
version = "1.1.17"
16+
version = "1.1.18"
1717
authors = ["The Dragonfly Developers"]
1818
homepage = "https://d7y.io/"
1919
repository = "https://github.com/dragonflyoss/client.git"
@@ -23,14 +23,14 @@ readme = "README.md"
2323
edition = "2021"
2424

2525
[workspace.dependencies]
26-
dragonfly-client = { path = "dragonfly-client", version = "1.1.17" }
27-
dragonfly-client-core = { path = "dragonfly-client-core", version = "1.1.17" }
28-
dragonfly-client-config = { path = "dragonfly-client-config", version = "1.1.17" }
29-
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "1.1.17" }
30-
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "1.1.17" }
31-
dragonfly-client-metric = { path = "dragonfly-client-metric", version = "1.1.17" }
32-
dragonfly-client-util = { path = "dragonfly-client-util", version = "1.1.17" }
33-
dragonfly-client-init = { path = "dragonfly-client-init", version = "1.1.17" }
26+
dragonfly-client = { path = "dragonfly-client", version = "1.1.18" }
27+
dragonfly-client-core = { path = "dragonfly-client-core", version = "1.1.18" }
28+
dragonfly-client-config = { path = "dragonfly-client-config", version = "1.1.18" }
29+
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "1.1.18" }
30+
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "1.1.18" }
31+
dragonfly-client-metric = { path = "dragonfly-client-metric", version = "1.1.18" }
32+
dragonfly-client-util = { path = "dragonfly-client-util", version = "1.1.18" }
33+
dragonfly-client-init = { path = "dragonfly-client-init", version = "1.1.18" }
3434
dragonfly-api = "=2.2.8"
3535
thiserror = "2.0"
3636
futures = "0.3.31"

dragonfly-client/src/proxy/mod.rs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ async fn proxy_via_dfdaemon(
981981

982982
/// proxy_via_http proxies the HTTP request directly to the remote server.
983983
#[instrument(skip_all)]
984-
async fn proxy_via_http(request: Request<hyper::body::Incoming>) -> ClientResult<Response> {
984+
async fn proxy_via_http(mut request: Request<hyper::body::Incoming>) -> ClientResult<Response> {
985985
let Some(host) = request.uri().host() else {
986986
error!("CONNECT host is not socket addr: {:?}", request.uri());
987987
return Ok(make_error_response(
@@ -1006,14 +1006,26 @@ async fn proxy_via_http(request: Request<hyper::body::Incoming>) -> ClientResult
10061006
}
10071007
});
10081008

1009+
// Override Host header with full authority (including port) to handle
1010+
// containerd's behavior with non-443 HTTPS ports, which otherwise
1011+
// causes request failures.
1012+
let authority = request
1013+
.uri()
1014+
.authority()
1015+
.ok_or_else(|| ClientError::Unknown("request uri authority is not set".to_string()))?
1016+
.as_str()
1017+
.parse()
1018+
.or_err(ErrorType::ParseError)?;
1019+
request.headers_mut().insert(hyper::header::HOST, authority);
1020+
10091021
let response = client.send_request(request).await?;
10101022
Ok(response.map(|b| b.map_err(ClientError::from).boxed()))
10111023
}
10121024

10131025
/// proxy_via_https proxies the HTTPS request directly to the remote server.
10141026
#[instrument(skip_all)]
10151027
async fn proxy_via_https(
1016-
request: Request<hyper::body::Incoming>,
1028+
mut request: Request<hyper::body::Incoming>,
10171029
registry_cert: Arc<Option<Vec<CertificateDer<'static>>>>,
10181030
) -> ClientResult<Response> {
10191031
let client_config_builder = match registry_cert.as_ref() {
@@ -1038,8 +1050,20 @@ async fn proxy_via_https(
10381050
.https_or_http()
10391051
.enable_http1()
10401052
.build();
1041-
10421053
let client = Client::builder(TokioExecutor::new()).build(https);
1054+
1055+
// Override Host header with full authority (including port) to handle
1056+
// containerd's behavior with non-443 HTTPS ports, which otherwise
1057+
// causes request failures.
1058+
let authority = request
1059+
.uri()
1060+
.authority()
1061+
.ok_or_else(|| ClientError::Unknown("request uri authority is not set".to_string()))?
1062+
.as_str()
1063+
.parse()
1064+
.or_err(ErrorType::ParseError)?;
1065+
request.headers_mut().insert(hyper::header::HOST, authority);
1066+
10431067
let response = client.request(request).await.inspect_err(|err| {
10441068
error!("request failed: {:?}", err);
10451069
})?;

0 commit comments

Comments
 (0)