From d922e35860fbf18db9fe8e20b65a3a55468df29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Thu, 7 Dec 2023 23:57:17 +0100 Subject: [PATCH] Add to nym-api node-describe-cache --- nym-api/nym-api-requests/src/models.rs | 9 +++++++++ nym-api/src/node_describe_cache/mod.rs | 13 ++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/nym-api/nym-api-requests/src/models.rs b/nym-api/nym-api-requests/src/models.rs index 35fad2b7c4..142a607e5a 100644 --- a/nym-api/nym-api-requests/src/models.rs +++ b/nym-api/nym-api-requests/src/models.rs @@ -366,6 +366,9 @@ pub struct NymNodeDescription { #[serde(default)] pub network_requester: Option, + #[serde(default)] + pub ip_packet_router: Option, + // for now we only care about their ws/wss situation, nothing more pub mixnet_websockets: WebSockets, } @@ -393,3 +396,9 @@ pub struct NetworkRequesterDetails { /// flag indicating whether this network requester uses the exit policy rather than the deprecated allow list pub uses_exit_policy: bool, } + +#[derive(Clone, Debug, Serialize, Deserialize, schemars::JsonSchema)] +pub struct IpPacketRouterDetails { + /// address of the embedded ip packet router + pub address: String, +} diff --git a/nym-api/src/node_describe_cache/mod.rs b/nym-api/src/node_describe_cache/mod.rs index 0a11a5224a..21b621f428 100644 --- a/nym-api/src/node_describe_cache/mod.rs +++ b/nym-api/src/node_describe_cache/mod.rs @@ -7,7 +7,9 @@ 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::{NetworkRequesterDetails, NymNodeDescription}; +use nym_api_requests::models::{ + IpPacketRouterDetails, NetworkRequesterDetails, NymNodeDescription, +}; use nym_config::defaults::{mainnet, DEFAULT_NYM_NODE_HTTP_PORT}; use nym_contracts_common::IdentityKey; use nym_mixnet_contract_common::Gateway; @@ -170,10 +172,19 @@ async fn get_gateway_description( None }; + let ip_packet_router = if let Ok(ipr) = client.get_ip_packet_router().await { + Some(IpPacketRouterDetails { + address: ipr.address, + }) + } else { + None + }; + let description = NymNodeDescription { host_information: host_info.data, build_information: build_info, network_requester, + ip_packet_router, mixnet_websockets: websockets, };