Explicit warning on missing fronting configuration

This commit is contained in:
durch
2025-09-01 12:25:25 +02:00
parent 72e1290d8f
commit edb797da68
3 changed files with 26 additions and 20 deletions
+1
View File
@@ -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"
+2 -2
View File
@@ -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 }
+23 -18
View File
@@ -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)