Remove domain fronting code to keep gateway changes only
This branch now contains only gateway registration improvements: - Multiple URL fallback support in gateways_for_init() - Get all entry-capable nodes for registration - Performance and code quality improvements
This commit is contained in:
Generated
-1
@@ -6790,7 +6790,6 @@ dependencies = [
|
||||
"nym-bandwidth-controller",
|
||||
"nym-credential-storage",
|
||||
"nym-credentials-interface",
|
||||
"nym-http-api-client",
|
||||
"nym-ip-packet-client",
|
||||
"nym-registration-common",
|
||||
"nym-sdk",
|
||||
|
||||
@@ -218,7 +218,6 @@ pub struct BaseClientBuilder<C, S: MixnetClientStorage> {
|
||||
shutdown: Option<ShutdownTracker>,
|
||||
event_tx: Option<EventSender>,
|
||||
user_agent: Option<UserAgent>,
|
||||
custom_nym_api_client: Option<nym_http_api_client::Client>,
|
||||
|
||||
setup_method: GatewaySetup,
|
||||
|
||||
@@ -248,7 +247,6 @@ where
|
||||
shutdown: None,
|
||||
event_tx: None,
|
||||
user_agent: None,
|
||||
custom_nym_api_client: None,
|
||||
setup_method: GatewaySetup::MustLoad { gateway_id: None },
|
||||
#[cfg(unix)]
|
||||
connection_fd_callback: None,
|
||||
@@ -256,12 +254,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_nym_api_client(mut self, client: nym_http_api_client::Client) -> Self {
|
||||
self.custom_nym_api_client = Some(client);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_derivation_material(
|
||||
mut self,
|
||||
@@ -873,17 +865,7 @@ where
|
||||
fn construct_nym_api_client(
|
||||
config: &Config,
|
||||
user_agent: Option<UserAgent>,
|
||||
custom_client: Option<nym_http_api_client::Client>,
|
||||
) -> Result<nym_http_api_client::Client, ClientCoreError> {
|
||||
// If a custom client was provided (e.g., with domain fronting support), use it
|
||||
if let Some(client) = custom_client {
|
||||
tracing::debug!("Using custom nym-api HTTP client");
|
||||
return Ok(client);
|
||||
}
|
||||
|
||||
tracing::debug!("Creating default nym-api HTTP client from config");
|
||||
|
||||
// Otherwise, create a basic client
|
||||
let mut nym_api_urls = config.get_nym_api_endpoints();
|
||||
nym_api_urls.shuffle(&mut thread_rng());
|
||||
|
||||
@@ -979,11 +961,7 @@ where
|
||||
.dkg_query_client
|
||||
.map(|client| BandwidthController::new(credential_store, client));
|
||||
|
||||
let nym_api_client = Self::construct_nym_api_client(
|
||||
&self.config,
|
||||
self.user_agent.clone(),
|
||||
self.custom_nym_api_client,
|
||||
)?;
|
||||
let nym_api_client = Self::construct_nym_api_client(&self.config, self.user_agent.clone())?;
|
||||
let key_rotation_config = Self::determine_key_rotation_state(&nym_api_client).await?;
|
||||
|
||||
let topology_provider = Self::setup_topology_provider(
|
||||
|
||||
@@ -23,7 +23,6 @@ nym-authenticator-client = { path = "../nym-authenticator-client" }
|
||||
nym-bandwidth-controller = { path = "../common/bandwidth-controller" }
|
||||
nym-credential-storage = { path = "../common/credential-storage" }
|
||||
nym-credentials-interface = { path = "../common/credentials-interface" }
|
||||
nym-http-api-client = { path = "../common/http-api-client" }
|
||||
nym-ip-packet-client = { path = "../nym-ip-packet-client" }
|
||||
nym-registration-common = { path = "../common/registration" }
|
||||
nym-sdk = { path = "../sdk/rust/nym-sdk" }
|
||||
|
||||
@@ -34,7 +34,6 @@ pub struct BuilderConfig {
|
||||
pub two_hops: bool,
|
||||
pub user_agent: UserAgent,
|
||||
pub custom_topology_provider: Box<dyn TopologyProvider + Send + Sync>,
|
||||
pub custom_nym_api_client: Option<nym_http_api_client::Client>,
|
||||
pub network_env: NymNetworkDetails,
|
||||
pub cancel_token: CancellationToken,
|
||||
#[cfg(unix)]
|
||||
@@ -57,9 +56,6 @@ pub struct MixnetClientConfig {
|
||||
}
|
||||
|
||||
impl BuilderConfig {
|
||||
/// Create a new BuilderConfig without domain fronting support
|
||||
///
|
||||
/// For domain fronting support, set `custom_nym_api_client` to Some(client) after creation
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
entry_node: NymNodeWithKeys,
|
||||
@@ -81,7 +77,6 @@ impl BuilderConfig {
|
||||
two_hops,
|
||||
user_agent,
|
||||
custom_topology_provider,
|
||||
custom_nym_api_client: None,
|
||||
network_env,
|
||||
cancel_token,
|
||||
#[cfg(unix)]
|
||||
@@ -89,12 +84,6 @@ impl BuilderConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/// Set a custom nym-api HTTP client (for domain fronting support)
|
||||
pub fn with_nym_api_client(mut self, client: nym_http_api_client::Client) -> Self {
|
||||
self.custom_nym_api_client = Some(client);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn mixnet_client_debug_config(&self) -> DebugConfig {
|
||||
if self.two_hops {
|
||||
two_hop_debug_config(&self.mixnet_client_config)
|
||||
@@ -147,7 +136,7 @@ impl BuilderConfig {
|
||||
RememberMe::new_mixnet()
|
||||
};
|
||||
|
||||
let mut builder = builder
|
||||
let builder = builder
|
||||
.with_user_agent(self.user_agent)
|
||||
.request_gateway(self.entry_node.node.identity.to_string())
|
||||
.network_details(self.network_env)
|
||||
@@ -156,11 +145,6 @@ impl BuilderConfig {
|
||||
.with_remember_me(remember_me)
|
||||
.custom_topology_provider(self.custom_topology_provider);
|
||||
|
||||
if let Some(nym_api_client) = self.custom_nym_api_client {
|
||||
tracing::debug!("Using custom nym-api HTTP client");
|
||||
builder = builder.with_nym_api_client(nym_api_client);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
let builder = builder.with_connection_fd_callback(self.connection_fd_callback);
|
||||
|
||||
@@ -263,23 +247,4 @@ mod tests {
|
||||
assert_eq!(config.min_mixnode_performance, None);
|
||||
assert_eq!(config.min_gateway_performance, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_builder_config_has_custom_client_field() {
|
||||
// Verify that BuilderConfig has the custom_nym_api_client field
|
||||
// by creating a simple HTTP client
|
||||
let http_client = nym_http_api_client::Client::builder(
|
||||
nym_http_api_client::Url::parse("https://validator.nymtech.net/api").unwrap(),
|
||||
)
|
||||
.expect("Failed to create client builder")
|
||||
.build()
|
||||
.expect("Failed to build client");
|
||||
|
||||
// Verify the client works
|
||||
let urls = http_client.base_urls();
|
||||
assert!(
|
||||
!urls.is_empty() && urls[0].as_str().contains("validator.nymtech.net"),
|
||||
"HTTP client should be configured with correct URL"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ pub struct MixnetClientBuilder<S: MixnetClientStorage = Ephemeral> {
|
||||
custom_topology_provider: Option<Box<dyn TopologyProvider + Send + Sync>>,
|
||||
custom_gateway_transceiver: Option<Box<dyn GatewayTransceiver + Send + Sync>>,
|
||||
custom_shutdown: Option<ShutdownTracker>,
|
||||
custom_nym_api_client: Option<nym_http_api_client::Client>,
|
||||
event_tx: Option<EventSender>,
|
||||
force_tls: bool,
|
||||
user_agent: Option<UserAgent>,
|
||||
@@ -94,7 +93,6 @@ impl MixnetClientBuilder<OnDiskPersistent> {
|
||||
socks5_config: None,
|
||||
wait_for_gateway: false,
|
||||
custom_topology_provider: None,
|
||||
custom_nym_api_client: None,
|
||||
storage: storage_paths
|
||||
.initialise_default_persistent_storage()
|
||||
.await?,
|
||||
@@ -133,7 +131,6 @@ where
|
||||
wait_for_gateway: false,
|
||||
custom_topology_provider: None,
|
||||
custom_gateway_transceiver: None,
|
||||
custom_nym_api_client: None,
|
||||
custom_shutdown: None,
|
||||
event_tx: None,
|
||||
force_tls: false,
|
||||
@@ -158,7 +155,6 @@ where
|
||||
wait_for_gateway: self.wait_for_gateway,
|
||||
custom_topology_provider: self.custom_topology_provider,
|
||||
custom_gateway_transceiver: self.custom_gateway_transceiver,
|
||||
custom_nym_api_client: self.custom_nym_api_client,
|
||||
custom_shutdown: self.custom_shutdown,
|
||||
event_tx: self.event_tx,
|
||||
force_tls: self.force_tls,
|
||||
@@ -298,12 +294,6 @@ where
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_nym_api_client(mut self, client: nym_http_api_client::Client) -> Self {
|
||||
self.custom_nym_api_client = Some(client);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_statistics_reporting(mut self, config: StatsReporting) -> Self {
|
||||
self.config.debug_config.stats_reporting = config;
|
||||
@@ -348,7 +338,6 @@ where
|
||||
|
||||
client.custom_gateway_transceiver = self.custom_gateway_transceiver;
|
||||
client.custom_topology_provider = self.custom_topology_provider;
|
||||
client.custom_nym_api_client = self.custom_nym_api_client;
|
||||
client.custom_shutdown = self.custom_shutdown;
|
||||
client.wait_for_gateway = self.wait_for_gateway;
|
||||
client.force_tls = self.force_tls;
|
||||
@@ -398,9 +387,6 @@ where
|
||||
/// advanced usage of custom gateways
|
||||
custom_gateway_transceiver: Option<Box<dyn GatewayTransceiver + Send + Sync>>,
|
||||
|
||||
/// Custom nym-api HTTP client (for domain fronting support)
|
||||
custom_nym_api_client: Option<nym_http_api_client::Client>,
|
||||
|
||||
/// Attempt to wait for the selected gateway (if applicable) to come online if its currently not bonded.
|
||||
wait_for_gateway: bool,
|
||||
|
||||
@@ -473,7 +459,6 @@ where
|
||||
storage,
|
||||
custom_topology_provider: None,
|
||||
custom_gateway_transceiver: None,
|
||||
custom_nym_api_client: None,
|
||||
wait_for_gateway: false,
|
||||
force_tls: false,
|
||||
custom_shutdown: None,
|
||||
@@ -731,11 +716,6 @@ where
|
||||
base_builder = base_builder.with_user_agent(user_agent);
|
||||
}
|
||||
|
||||
if let Some(nym_api_client) = self.custom_nym_api_client {
|
||||
tracing::debug!("Using custom nym-api HTTP client");
|
||||
base_builder = base_builder.with_nym_api_client(nym_api_client);
|
||||
}
|
||||
|
||||
if let Some(topology_provider) = self.custom_topology_provider {
|
||||
base_builder = base_builder.with_topology_provider(topology_provider);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user