From edb797da6877c1f9d71407175f3188a82ff29a5b Mon Sep 17 00:00:00 2001 From: durch Date: Mon, 1 Sep 2025 12:25:25 +0200 Subject: [PATCH] Explicit warning on missing fronting configuration --- Cargo.toml | 1 + common/http-api-client/Cargo.toml | 4 +-- common/http-api-client/src/lib.rs | 41 +++++++++++++++++-------------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 06a754e579..9d8a3b7cf4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -318,6 +318,7 @@ serde_json_path = "0.7.2" serde_repr = "0.1" serde_with = "3.9.0" serde_yaml = "0.9.25" +serde_plain = "1.0.2" sha2 = "0.10.9" si-scale = "0.2.3" snow = "0.9.6" diff --git a/common/http-api-client/Cargo.toml b/common/http-api-client/Cargo.toml index 3719960aef..66c0f94695 100644 --- a/common/http-api-client/Cargo.toml +++ b/common/http-api-client/Cargo.toml @@ -24,8 +24,8 @@ url = { workspace = true } once_cell = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } -serde_yaml = "0.9.34-deprecated" -serde_plain = "1.0.2" +serde_yaml = { workspace = true} +serde_plain = { workspace = true } thiserror = { workspace = true } tracing = { workspace = true } itertools = { workspace = true } diff --git a/common/http-api-client/src/lib.rs b/common/http-api-client/src/lib.rs index 57f78e8b74..9004480734 100644 --- a/common/http-api-client/src/lib.rs +++ b/common/http-api-client/src/lib.rs @@ -802,27 +802,32 @@ impl Client { #[cfg(feature = "tunneling")] if let Some(ref front) = self.front { if front.is_enabled() { - let front_host = url.front_str().unwrap_or(""); - let actual_host = url.host_str().unwrap_or(""); + if let Some(front_host) = url.front_str() { + if let Some(actual_host) = url.host_str() { + tracing::debug!( + "Domain fronting enabled: routing via CDN {} to actual host {}", + front_host, + actual_host + ); - tracing::debug!( - "Domain fronting enabled: routing via CDN {} to actual host {}", - front_host, - actual_host - ); + // this should never fail as we are transplanting the host from one url to another + r.url_mut().set_host(Some(front_host)).unwrap(); - // this should never fail as we are transplanting the host from one url to another - r.url_mut().set_host(Some(front_host)).unwrap(); + let actual_host_header: HeaderValue = + actual_host.parse().unwrap_or(HeaderValue::from_static("")); + // If the map did have this key present, the new value is associated with the key + // and all previous values are removed. (reqwest HeaderMap docs) + _ = r + .headers_mut() + .insert(reqwest::header::HOST, actual_host_header); - let actual_host_header: HeaderValue = - actual_host.parse().unwrap_or(HeaderValue::from_static("")); - // If the map did have this key present, the new value is associated with the key - // and all previous values are removed. (reqwest HeaderMap docs) - _ = r - .headers_mut() - .insert(reqwest::header::HOST, actual_host_header); - - return (url.as_str(), url.front_str()); + return (url.as_str(), url.front_str()); + } else { + warn!("Domain fronting is enabled, but no host_url is defined! Domain fronting WILL NOT WORK") + } + } else { + warn!("Domain fronting is enabled, but no front_url is defined! Domain fronting WILL NOT WORK") + } } } (url.as_str(), None)