augment self described API with NoiseInformation field
This commit is contained in:
@@ -12,6 +12,7 @@ use nym_network_requester::RequestFilter;
|
||||
use nym_node::error::NymNodeError;
|
||||
use nym_node::http::api::api_requests;
|
||||
use nym_node::http::api::api_requests::v1::network_requester::exit_policy::models::UsedExitPolicy;
|
||||
use nym_node::http::api::api_requests::v1::node::models::NoiseInformation;
|
||||
use nym_node::http::api::api_requests::SignedHostInformation;
|
||||
use nym_node::http::router::WireguardAppState;
|
||||
use nym_node::wireguard::types::GatewayClientRegistry;
|
||||
@@ -260,6 +261,7 @@ impl<'a> HttpApiBuilder<'a> {
|
||||
self.sphinx_keypair.public_key(),
|
||||
self.identity_keypair,
|
||||
)?,
|
||||
NoiseInformation { supported: true }, //this field somes with Noise support, so we can hardcode it (to ultimately remove it once it's granted)
|
||||
)
|
||||
.with_gateway(load_gateway_details(self.gateway_config)?)
|
||||
.with_landing_page_assets(self.gateway_config.http.landing_page_assets_path.as_ref());
|
||||
|
||||
@@ -11,6 +11,7 @@ use nym_bin_common::bin_info_owned;
|
||||
use nym_crypto::asymmetric::{encryption, identity};
|
||||
use nym_node::error::NymNodeError;
|
||||
use nym_node::http::api::api_requests;
|
||||
use nym_node::http::api::api_requests::v1::node::models::NoiseInformation;
|
||||
use nym_node::http::api::api_requests::SignedHostInformation;
|
||||
use nym_task::TaskClient;
|
||||
|
||||
@@ -93,6 +94,7 @@ impl<'a> HttpApiBuilder<'a> {
|
||||
self.sphinx_keypair.public_key(),
|
||||
self.identity_keypair,
|
||||
)?,
|
||||
NoiseInformation { supported: true }, //this field somes with Noise support, so we can hardcode it (to ultimately remove it once it's granted)
|
||||
)
|
||||
.with_mixnode(load_mixnode_details(self.mixnode_config)?)
|
||||
.with_landing_page_assets(self.mixnode_config.http.landing_page_assets_path.as_ref());
|
||||
|
||||
@@ -42,3 +42,9 @@ pub struct HostKeys {
|
||||
/// Currently it corresponds to either mixnode's or gateway's key.
|
||||
pub x25519: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Debug, Clone, JsonSchema)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
pub struct NoiseInformation {
|
||||
pub supported: bool,
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ pub mod routes {
|
||||
pub const ROLES: &str = "/roles";
|
||||
pub const BUILD_INFO: &str = "/build-information";
|
||||
pub const HOST_INFO: &str = "/host-information";
|
||||
pub const NOISE_INFO: &str = "/noise";
|
||||
|
||||
pub const HEALTH: &str = "/health";
|
||||
pub const GATEWAY: &str = "/gateway";
|
||||
@@ -45,6 +46,7 @@ pub mod routes {
|
||||
absolute_route!(mixnode_absolute, v1_absolute(), MIXNODE);
|
||||
absolute_route!(network_requester_absolute, v1_absolute(), NETWORK_REQUESTER);
|
||||
absolute_route!(ip_packet_router_absolute, v1_absolute(), IP_PACKET_ROUTER);
|
||||
absolute_route!(noise_info_absolute, v1_absolute(), NOISE_INFO);
|
||||
absolute_route!(swagger_absolute, v1_absolute(), SWAGGER);
|
||||
|
||||
pub mod gateway {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
use crate::http::api::v1::node::build_information::build_information;
|
||||
use crate::http::api::v1::node::host_information::host_information;
|
||||
use crate::http::api::v1::node::noise_information::noise_information;
|
||||
use crate::http::api::v1::node::roles::roles;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
@@ -11,12 +12,14 @@ use nym_node_requests::routes::api::v1;
|
||||
|
||||
pub mod build_information;
|
||||
pub mod host_information;
|
||||
pub mod noise_information;
|
||||
pub mod roles;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Config {
|
||||
pub build_information: models::BinaryBuildInformationOwned,
|
||||
pub host_information: models::SignedHostInformation,
|
||||
pub noise_information: models::NoiseInformation,
|
||||
pub roles: models::NodeRoles,
|
||||
}
|
||||
|
||||
@@ -43,4 +46,11 @@ pub(super) fn routes<S: Send + Sync + 'static + Clone>(config: Config) -> Router
|
||||
move |query| host_information(host_info, query)
|
||||
}),
|
||||
)
|
||||
.route(
|
||||
v1::NOISE_INFO,
|
||||
get({
|
||||
let noise_info = config.noise_information;
|
||||
move |query| noise_information(noise_info, query)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::http::api::{FormattedResponse, OutputParams};
|
||||
use axum::extract::Query;
|
||||
use nym_node_requests::api::v1::node::models::NoiseInformation;
|
||||
|
||||
/// Returns host information of this node.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/noise",
|
||||
context_path = "/api/v1",
|
||||
tag = "Node",
|
||||
responses(
|
||||
(status = 200, content(
|
||||
("application/json" = NoiseInformation),
|
||||
("application/yaml" = NoiseInformation)
|
||||
))
|
||||
),
|
||||
params(OutputParams)
|
||||
)]
|
||||
pub(crate) async fn noise_information(
|
||||
host_information: NoiseInformation,
|
||||
Query(output): Query<OutputParams>,
|
||||
) -> NoiseInformationResponse {
|
||||
let output = output.output.unwrap_or_default();
|
||||
output.to_response(host_information)
|
||||
}
|
||||
|
||||
pub type NoiseInformationResponse = FormattedResponse<NoiseInformation>;
|
||||
@@ -12,7 +12,7 @@ use nym_node_requests::api::v1::ip_packet_router::models::IpPacketRouter;
|
||||
use nym_node_requests::api::v1::mixnode::models::Mixnode;
|
||||
use nym_node_requests::api::v1::network_requester::exit_policy::models::UsedExitPolicy;
|
||||
use nym_node_requests::api::v1::network_requester::models::NetworkRequester;
|
||||
use nym_node_requests::api::v1::node::models;
|
||||
use nym_node_requests::api::v1::node::models::{self, NoiseInformation};
|
||||
use nym_node_requests::api::SignedHostInformation;
|
||||
use nym_node_requests::routes;
|
||||
use std::net::SocketAddr;
|
||||
@@ -33,6 +33,7 @@ impl Config {
|
||||
pub fn new(
|
||||
build_information: models::BinaryBuildInformationOwned,
|
||||
host_information: SignedHostInformation,
|
||||
noise_information: NoiseInformation,
|
||||
) -> Self {
|
||||
Config {
|
||||
landing: Default::default(),
|
||||
@@ -41,6 +42,7 @@ impl Config {
|
||||
node: api::v1::node::Config {
|
||||
build_information,
|
||||
host_information,
|
||||
noise_information,
|
||||
roles: Default::default(),
|
||||
},
|
||||
gateway: Default::default(),
|
||||
|
||||
Reference in New Issue
Block a user