Feature/gateway described nr (#4147)
* adding embedded NR information to gateways/described endpoint * using default for NR if not available
This commit is contained in:
committed by
GitHub
parent
a5c1e4abf0
commit
4a5ceddeac
@@ -363,6 +363,9 @@ pub struct NymNodeDescription {
|
||||
// TODO: do we really care about ALL build info or just the version?
|
||||
pub build_information: BinaryBuildInformationOwned,
|
||||
|
||||
#[serde(default)]
|
||||
pub network_requester: Option<NetworkRequesterDetails>,
|
||||
|
||||
// for now we only care about their ws/wss situation, nothing more
|
||||
pub mixnet_websockets: WebSockets,
|
||||
}
|
||||
@@ -381,3 +384,12 @@ impl From<GatewayBond> for DescribedGateway {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, schemars::JsonSchema)]
|
||||
pub struct NetworkRequesterDetails {
|
||||
/// address of the embedded network requester
|
||||
pub address: String,
|
||||
|
||||
/// flag indicating whether this network requester uses the exit policy rather than the deprecated allow list
|
||||
pub uses_exit_policy: bool,
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ use crate::support::caching::refresher::{CacheItemProvider, CacheRefresher};
|
||||
use crate::support::config;
|
||||
use crate::support::config::DEFAULT_NODE_DESCRIBE_BATCH_SIZE;
|
||||
use futures_util::{stream, StreamExt};
|
||||
use nym_api_requests::models::NymNodeDescription;
|
||||
use nym_config::defaults::DEFAULT_NYM_NODE_HTTP_PORT;
|
||||
use nym_api_requests::models::{NetworkRequesterDetails, NymNodeDescription};
|
||||
use nym_config::defaults::{mainnet, DEFAULT_NYM_NODE_HTTP_PORT};
|
||||
use nym_contracts_common::IdentityKey;
|
||||
use nym_mixnet_contract_common::Gateway;
|
||||
use nym_node_requests::api::client::{NymNodeApiClientError, NymNodeApiClientExt};
|
||||
@@ -152,9 +152,28 @@ async fn get_gateway_description(
|
||||
source: err,
|
||||
})?;
|
||||
|
||||
let network_requester =
|
||||
if let Ok(nr) = client.get_network_requester().await {
|
||||
let exit_policy = client.get_exit_policy().await.map_err(|err| {
|
||||
NodeDescribeCacheError::ApiFailure {
|
||||
gateway: gateway.identity_key.clone(),
|
||||
source: err,
|
||||
}
|
||||
})?;
|
||||
let uses_nym_exit_policy = exit_policy.upstream_source == mainnet::EXIT_POLICY_URL;
|
||||
|
||||
Some(NetworkRequesterDetails {
|
||||
address: nr.address,
|
||||
uses_exit_policy: exit_policy.enabled && uses_nym_exit_policy,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let description = NymNodeDescription {
|
||||
host_information: host_info.data,
|
||||
build_information: build_info,
|
||||
network_requester,
|
||||
mixnet_websockets: websockets,
|
||||
};
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ use nym_bin_common::build_information::BinaryBuildInformationOwned;
|
||||
use nym_wireguard_types::{ClientMessage, ClientRegistrationResponse};
|
||||
|
||||
use crate::api::v1::health::models::NodeHealth;
|
||||
use crate::api::v1::network_requester::exit_policy::models::UsedExitPolicy;
|
||||
use crate::api::v1::network_requester::models::NetworkRequester;
|
||||
pub use http_api_client::Client;
|
||||
|
||||
pub type NymNodeApiClientError = HttpClientError<ErrorResponse>;
|
||||
@@ -42,6 +44,16 @@ pub trait NymNodeApiClientExt: ApiClient {
|
||||
.await
|
||||
}
|
||||
|
||||
async fn get_network_requester(&self) -> Result<NetworkRequester, NymNodeApiClientError> {
|
||||
self.get_json_from(routes::api::v1::network_requester_absolute())
|
||||
.await
|
||||
}
|
||||
|
||||
async fn get_exit_policy(&self) -> Result<UsedExitPolicy, NymNodeApiClientError> {
|
||||
self.get_json_from(routes::api::v1::network_requester::exit_policy_absolute())
|
||||
.await
|
||||
}
|
||||
|
||||
async fn post_gateway_register_client(
|
||||
&self,
|
||||
client_message: &ClientMessage,
|
||||
|
||||
Reference in New Issue
Block a user