Refactor domain fronting to use configuration-based approach
How it works: 1. VPN configures NymNetworkDetails with front_hosts 2. SDK passes network_details to BaseClientBuilder via with_network_details() 3. BaseClientBuilder uses ClientBuilder::from_network() when available 4. from_network() automatically enables domain fronting if front_hosts configured Benefits: - Configuration-based (network_details), not object-based (cleaner) - No breaking changes for existing clients Changes: - Added network_details: Option<NymNetworkDetails> to BaseClientBuilder - Updated tests
This commit is contained in:
@@ -594,10 +594,9 @@ impl ClientBuilder {
|
||||
let urls = network
|
||||
.nym_api_urls
|
||||
.as_ref()
|
||||
.ok_or_else(|| {
|
||||
HttpClientError::GenericRequestFailure(
|
||||
"No API URLs configured in network details".to_string(),
|
||||
)
|
||||
.ok_or_else(|| HttpClientError::InternalResponseInconsistency {
|
||||
url: ::url::Url::parse("about:blank").unwrap(),
|
||||
details: "No API URLs configured in network details".to_string(),
|
||||
})?
|
||||
.iter()
|
||||
.map(|api_url| {
|
||||
@@ -611,8 +610,12 @@ impl ClientBuilder {
|
||||
.iter()
|
||||
.map(|host| format!("https://{}", host))
|
||||
.collect();
|
||||
url = Url::new(api_url.url.clone(), Some(fronts))
|
||||
.map_err(|e| HttpClientError::GenericRequestFailure(e.to_string()))?;
|
||||
url = Url::new(api_url.url.clone(), Some(fronts)).map_err(|e| {
|
||||
HttpClientError::MalformedUrl {
|
||||
raw: api_url.url.clone(),
|
||||
source: e,
|
||||
}
|
||||
})?;
|
||||
}
|
||||
|
||||
Ok(url)
|
||||
|
||||
Reference in New Issue
Block a user