moved all models to separate crate
This commit is contained in:
@@ -94,6 +94,7 @@ members = [
|
||||
"nym-browser-extension/storage",
|
||||
"nym-api/nym-api-requests",
|
||||
"nym-node",
|
||||
"nym-node/nym-node-requests",
|
||||
"nym-outfox",
|
||||
"tools/internal/ssl-inject",
|
||||
"tools/internal/sdk-version-bump",
|
||||
|
||||
+25
-21
@@ -6,19 +6,20 @@ use crate::error::GatewayError;
|
||||
use crate::node::helpers::{load_identity_keys, load_public_key};
|
||||
use nym_bin_common::bin_info_owned;
|
||||
use nym_crypto::asymmetric::{encryption, identity};
|
||||
use nym_node::http;
|
||||
use nym_node::http::api::SignedHostInformation;
|
||||
use nym_node::error::NymNodeError;
|
||||
use nym_node::http::api::api_requests;
|
||||
use nym_node::http::api::api_requests::SignedHostInformation;
|
||||
use nym_sphinx::addressing::clients::Recipient;
|
||||
use nym_task::TaskClient;
|
||||
use zeroize::Zeroize;
|
||||
|
||||
fn load_gateway_details(
|
||||
config: &Config,
|
||||
) -> Result<http::api::v1::gateway::types::Gateway, GatewayError> {
|
||||
Ok(http::api::v1::gateway::types::Gateway {
|
||||
client_interfaces: http::api::v1::gateway::types::ClientInterfaces {
|
||||
) -> Result<api_requests::v1::gateway::models::Gateway, GatewayError> {
|
||||
Ok(api_requests::v1::gateway::models::Gateway {
|
||||
client_interfaces: api_requests::v1::gateway::models::ClientInterfaces {
|
||||
wireguard: None,
|
||||
mixnet_websockets: Some(http::api::v1::gateway::types::WebSockets {
|
||||
mixnet_websockets: Some(api_requests::v1::gateway::models::WebSockets {
|
||||
ws_port: config.gateway.clients_port,
|
||||
wss_port: None,
|
||||
}),
|
||||
@@ -28,7 +29,7 @@ fn load_gateway_details(
|
||||
|
||||
fn load_host_details(
|
||||
config: &Config,
|
||||
) -> Result<http::api::v1::node::types::SignedHostInformation, GatewayError> {
|
||||
) -> Result<api_requests::v1::node::models::SignedHostInformation, GatewayError> {
|
||||
let mut identity_keypair = load_identity_keys(config)?;
|
||||
|
||||
let sphinx_public_key: encryption::PublicKey = load_public_key(
|
||||
@@ -36,17 +37,18 @@ fn load_host_details(
|
||||
"gateway sphinx",
|
||||
)?;
|
||||
|
||||
let host_info = http::api::v1::node::types::HostInformation {
|
||||
let host_info = api_requests::v1::node::models::HostInformation {
|
||||
// TODO: this should be extracted differently, i.e. it's the issue of the public/private address
|
||||
ip_address: vec![config.gateway.listening_address.to_string()],
|
||||
hostname: None,
|
||||
keys: http::api::v1::node::types::HostKeys {
|
||||
keys: api_requests::v1::node::models::HostKeys {
|
||||
ed25519: identity_keypair.public_key().to_base58_string(),
|
||||
x25519: sphinx_public_key.to_base58_string(),
|
||||
},
|
||||
};
|
||||
|
||||
let signed_info = SignedHostInformation::new(host_info, identity_keypair.private_key())?;
|
||||
let signed_info = SignedHostInformation::new(host_info, identity_keypair.private_key())
|
||||
.map_err(NymNodeError::from)?;
|
||||
identity_keypair.zeroize();
|
||||
Ok(signed_info)
|
||||
}
|
||||
@@ -54,7 +56,7 @@ fn load_host_details(
|
||||
fn load_network_requester_details(
|
||||
config: &Config,
|
||||
network_requester_config: &nym_network_requester::Config,
|
||||
) -> Result<http::api::v1::network_requester::types::NetworkRequester, GatewayError> {
|
||||
) -> Result<api_requests::v1::network_requester::models::NetworkRequester, GatewayError> {
|
||||
let identity_public_key: identity::PublicKey = load_public_key(
|
||||
&network_requester_config
|
||||
.storage_paths
|
||||
@@ -78,16 +80,18 @@ fn load_network_requester_details(
|
||||
"gateway identity",
|
||||
)?;
|
||||
|
||||
Ok(http::api::v1::network_requester::types::NetworkRequester {
|
||||
encoded_identity_key: identity_public_key.to_base58_string(),
|
||||
encoded_x25519_key: dh_public_key.to_base58_string(),
|
||||
address: Recipient::new(
|
||||
identity_public_key,
|
||||
dh_public_key,
|
||||
gateway_identity_public_key,
|
||||
)
|
||||
.to_string(),
|
||||
})
|
||||
Ok(
|
||||
api_requests::v1::network_requester::models::NetworkRequester {
|
||||
encoded_identity_key: identity_public_key.to_base58_string(),
|
||||
encoded_x25519_key: dh_public_key.to_base58_string(),
|
||||
address: Recipient::new(
|
||||
identity_public_key,
|
||||
dh_public_key,
|
||||
gateway_identity_public_key,
|
||||
)
|
||||
.to_string(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn start_http_api(
|
||||
|
||||
@@ -11,7 +11,7 @@ cosmrs = { workspace = true }
|
||||
cosmwasm-std = { workspace = true }
|
||||
getset = "0.1.1"
|
||||
schemars = { version = "0.8", features = ["preserve_order"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
ts-rs = { workspace = true, optional = true }
|
||||
|
||||
nym-coconut-interface = { path = "../../common/coconut-interface" }
|
||||
|
||||
+1
-2
@@ -42,6 +42,5 @@ utoipa-swagger-ui = { workspace = true, features = ["axum"] }
|
||||
#utoipa-rapidoc = { version = "0.1.0", features = ["axum"] }
|
||||
|
||||
|
||||
nym-bin-common = { path = "../common/bin-common", features = ["openapi"] }
|
||||
nym-crypto = { path = "../common/crypto", features = ["asymmetric"] }
|
||||
nym-node-requests = { path = "nym-node-requests", default-features = false, features = ["openapi"]}
|
||||
nym-task = { path = "../common/task" }
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "nym-node-requests"
|
||||
version = "0.1.0"
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
documentation.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
utoipa = { workspace = true, optional = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true, optional = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
nym-bin-common = { path = "../../common/bin-common", optional = true, features = ["openapi"] }
|
||||
nym-crypto = { path = "../../common/crypto", features = ["asymmetric"] }
|
||||
|
||||
[features]
|
||||
default = ["client"]
|
||||
client = []
|
||||
openapi = ["utoipa", "nym-bin-common", "serde_json"]
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::api::v1::node::models::HostInformation;
|
||||
use crate::error::Error;
|
||||
use nym_crypto::asymmetric::identity;
|
||||
use serde::Serialize;
|
||||
use std::ops::Deref;
|
||||
|
||||
pub mod v1;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
#[cfg_attr(feature = "openapi", aliases(SignedHostInformation = SignedData<HostInformation>))]
|
||||
pub struct SignedData<T> {
|
||||
// #[serde(flatten)]
|
||||
pub data: T,
|
||||
pub signature: String,
|
||||
}
|
||||
|
||||
impl<T> SignedData<T> {
|
||||
pub fn new(data: T, key: &identity::PrivateKey) -> Result<Self, Error>
|
||||
where
|
||||
T: Serialize,
|
||||
{
|
||||
let plaintext = serde_json::to_string(&data)?;
|
||||
let signature = key.sign(plaintext).to_base58_string();
|
||||
Ok(SignedData { data, signature })
|
||||
}
|
||||
|
||||
pub fn verify(&self, key: &identity::PublicKey) -> bool
|
||||
where
|
||||
T: Serialize,
|
||||
{
|
||||
let Ok(plaintext) = serde_json::to_string(&self.data) else {
|
||||
return false;
|
||||
};
|
||||
let Ok(signature) = identity::Signature::from_base58_string(&self.signature) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
key.verify(plaintext, &signature).is_ok()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Deref for SignedData<T> {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.data
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub mod models;
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
pub struct Gateway {
|
||||
pub client_interfaces: ClientInterfaces,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
pub struct Wireguard {
|
||||
#[cfg_attr(feature = "openapi", schema(example = 51820, default = 51820))]
|
||||
pub port: u16,
|
||||
|
||||
pub public_key: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
pub struct ClientInterfaces {
|
||||
pub wireguard: Option<Wireguard>,
|
||||
|
||||
pub mixnet_websockets: Option<WebSockets>,
|
||||
// pub mixnet_tcp:
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone, Copy)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
pub struct WebSockets {
|
||||
#[cfg_attr(feature = "openapi", schema(example = 9000, default = 9000))]
|
||||
pub ws_port: u16,
|
||||
|
||||
pub wss_port: Option<u16>,
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub mod models;
|
||||
+2
-2
@@ -2,9 +2,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use serde::Serialize;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
#[derive(Serialize, Debug, Clone, ToSchema)]
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
pub struct Mixnode {
|
||||
// /// Base58 encoded ed25519 EdDSA public key of the mixnode.
|
||||
// pub encoded_identity_key: String,
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub mod gateway;
|
||||
pub mod mixnode;
|
||||
pub mod network_requester;
|
||||
pub mod node;
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub mod models;
|
||||
+2
-2
@@ -2,9 +2,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use serde::Serialize;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
#[derive(Serialize, Debug, Clone, ToSchema)]
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
pub struct NetworkRequester {
|
||||
/// Base58 encoded ed25519 EdDSA public key of the network requester.
|
||||
pub encoded_identity_key: String,
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub mod models;
|
||||
+9
-6
@@ -1,19 +1,21 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub use crate::http::api::SignedHostInformation;
|
||||
pub use nym_bin_common::build_information::BinaryBuildInformationOwned;
|
||||
use serde::Serialize;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
#[derive(Clone, Default, Debug, Copy, ToSchema, Serialize)]
|
||||
pub use crate::api::SignedHostInformation;
|
||||
pub use nym_bin_common::build_information::BinaryBuildInformationOwned;
|
||||
|
||||
#[derive(Clone, Default, Debug, Copy, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
pub struct NodeRoles {
|
||||
pub mixnode_enabled: bool,
|
||||
pub gateway_enabled: bool,
|
||||
pub network_requester_enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Debug, ToSchema, Serialize)]
|
||||
#[derive(Clone, Default, Debug, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
pub struct HostInformation {
|
||||
/// Ip address(es) of this host, such as `1.1.1.1`.
|
||||
pub ip_address: Vec<String>,
|
||||
@@ -25,7 +27,8 @@ pub struct HostInformation {
|
||||
pub keys: HostKeys,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Debug, ToSchema, Serialize)]
|
||||
#[derive(Clone, Default, Debug, Serialize)]
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
pub struct HostKeys {
|
||||
/// Base58-encoded ed25519 public key of this node. Currently it corresponds to either mixnode's or gateway's identity.
|
||||
pub ed25519: String,
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
#[error("failed to serialize json data: {source}")]
|
||||
JsonSerializationFailure {
|
||||
#[from]
|
||||
source: serde_json::Error,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub mod api;
|
||||
pub mod error;
|
||||
@@ -12,10 +12,10 @@ pub enum NymNodeError {
|
||||
source: hyper::Error,
|
||||
},
|
||||
|
||||
#[error("failed to serialize json data: {source}")]
|
||||
JsonSerializationFailure {
|
||||
#[error("failed to use nym-node requests: {source}")]
|
||||
RequestError {
|
||||
#[from]
|
||||
source: serde_json::Error,
|
||||
source: nym_node_requests::error::Error,
|
||||
},
|
||||
|
||||
#[error("unimplemented")]
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::error::NymNodeError;
|
||||
use crate::http::api::v1::node::types::HostInformation;
|
||||
use crate::http::state::AppState;
|
||||
use axum::http::{header, HeaderValue, StatusCode};
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use axum::{Json, Router};
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use nym_crypto::asymmetric::identity;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::ops::Deref;
|
||||
use utoipa::{IntoParams, ToSchema};
|
||||
|
||||
pub mod v1;
|
||||
|
||||
pub use nym_node_requests::api as api_requests;
|
||||
|
||||
pub(crate) mod routes {
|
||||
pub(crate) const V1: &str = "/v1";
|
||||
}
|
||||
@@ -28,47 +26,6 @@ pub(super) fn routes(config: Config) -> Router<AppState> {
|
||||
Router::new().nest(routes::V1, v1::routes(config.v1_config))
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, ToSchema, Serialize)]
|
||||
#[aliases(SignedHostInformation = SignedData<HostInformation>)]
|
||||
pub struct SignedData<T> {
|
||||
// #[serde(flatten)]
|
||||
pub data: T,
|
||||
pub signature: String,
|
||||
}
|
||||
|
||||
impl<T> SignedData<T> {
|
||||
pub fn new(data: T, key: &identity::PrivateKey) -> Result<Self, NymNodeError>
|
||||
where
|
||||
T: Serialize,
|
||||
{
|
||||
let plaintext = serde_json::to_string(&data)?;
|
||||
let signature = key.sign(plaintext).to_base58_string();
|
||||
Ok(SignedData { data, signature })
|
||||
}
|
||||
|
||||
pub fn verify(&self, key: &identity::PublicKey) -> bool
|
||||
where
|
||||
T: Serialize,
|
||||
{
|
||||
let Ok(plaintext) = serde_json::to_string(&self.data) else {
|
||||
return false;
|
||||
};
|
||||
let Ok(signature) = identity::Signature::from_base58_string(&self.signature) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
key.verify(plaintext, &signature).is_ok()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Deref for SignedData<T> {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.data
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, ToSchema)]
|
||||
pub enum FormattedResponse<T> {
|
||||
Json(Json<T>),
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::http::api::v1::gateway::types::{ClientInterfaces, WebSockets, Wireguard};
|
||||
use crate::http::api::{FormattedResponse, OutputParams};
|
||||
use crate::http::state::AppState;
|
||||
use axum::extract::Query;
|
||||
use axum::http::StatusCode;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use nym_node_requests::api::v1::gateway::models::{ClientInterfaces, WebSockets, Wireguard};
|
||||
|
||||
pub(crate) mod routes {
|
||||
pub(crate) const INTERFACES: &str = "/";
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
use crate::http::state::AppState;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use nym_node_requests::api::v1::gateway::models;
|
||||
|
||||
pub mod client_interfaces;
|
||||
pub mod root;
|
||||
pub mod types;
|
||||
|
||||
pub(crate) mod routes {
|
||||
pub(crate) const ROOT: &str = "/";
|
||||
@@ -16,7 +16,7 @@ pub(crate) mod routes {
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Config {
|
||||
pub details: Option<types::Gateway>,
|
||||
pub details: Option<models::Gateway>,
|
||||
}
|
||||
|
||||
pub(crate) fn routes(config: Config) -> Router<AppState> {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::http::api::v1::gateway::types::Gateway;
|
||||
use crate::http::router::api::{FormattedResponse, OutputParams};
|
||||
use axum::extract::Query;
|
||||
use axum::http::StatusCode;
|
||||
use nym_node_requests::api::v1::gateway::models::Gateway;
|
||||
|
||||
/// Returns root gateway information
|
||||
#[utoipa::path(
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use serde::Serialize;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
#[derive(Serialize, Debug, Clone, ToSchema)]
|
||||
pub struct Gateway {
|
||||
pub client_interfaces: ClientInterfaces,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone, ToSchema)]
|
||||
pub struct Wireguard {
|
||||
#[schema(example = 1234, default = 51820)]
|
||||
pub port: u16,
|
||||
|
||||
pub public_key: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone, ToSchema)]
|
||||
pub struct ClientInterfaces {
|
||||
pub wireguard: Option<Wireguard>,
|
||||
|
||||
pub mixnet_websockets: Option<WebSockets>,
|
||||
// pub mixnet_tcp:
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone, Copy, ToSchema)]
|
||||
pub struct WebSockets {
|
||||
#[schema(example = 1234, default = 9000)]
|
||||
pub ws_port: u16,
|
||||
|
||||
pub wss_port: Option<u16>,
|
||||
}
|
||||
@@ -4,9 +4,9 @@
|
||||
use crate::http::state::AppState;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use nym_node_requests::api::v1::mixnode::models;
|
||||
|
||||
pub mod root;
|
||||
pub mod types;
|
||||
|
||||
pub(crate) mod routes {
|
||||
pub(crate) const ROOT: &str = "/";
|
||||
@@ -14,7 +14,7 @@ pub(crate) mod routes {
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Config {
|
||||
pub details: Option<types::Mixnode>,
|
||||
pub details: Option<models::Mixnode>,
|
||||
}
|
||||
|
||||
pub(crate) fn routes(config: Config) -> Router<AppState> {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::http::api::v1::mixnode::types::Mixnode;
|
||||
use crate::http::router::api::{FormattedResponse, OutputParams};
|
||||
use axum::extract::Query;
|
||||
use axum::http::StatusCode;
|
||||
use nym_node_requests::api::v1::mixnode::models::Mixnode;
|
||||
|
||||
/// Returns root mixnode information
|
||||
#[utoipa::path(
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
use crate::http::state::AppState;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use nym_node_requests::api::v1::network_requester::models;
|
||||
|
||||
pub mod root;
|
||||
pub mod types;
|
||||
|
||||
pub(crate) mod routes {
|
||||
pub(crate) const ROOT: &str = "/";
|
||||
@@ -14,7 +14,7 @@ pub(crate) mod routes {
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Config {
|
||||
pub details: Option<types::NetworkRequester>,
|
||||
pub details: Option<models::NetworkRequester>,
|
||||
}
|
||||
|
||||
pub(crate) fn routes(config: Config) -> Router<AppState> {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::http::api::v1::network_requester::types::NetworkRequester;
|
||||
use crate::http::router::api::{FormattedResponse, OutputParams};
|
||||
use axum::extract::Query;
|
||||
use axum::http::StatusCode;
|
||||
use nym_node_requests::api::v1::network_requester::models::NetworkRequester;
|
||||
|
||||
/// Returns root network requester information
|
||||
#[utoipa::path(
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::http::router::api::{FormattedResponse, OutputParams};
|
||||
use axum::extract::Query;
|
||||
use nym_bin_common::build_information::BinaryBuildInformationOwned;
|
||||
use nym_node_requests::api::v1::node::models::BinaryBuildInformationOwned;
|
||||
|
||||
/// Returns build metadata of the binary running the API
|
||||
#[utoipa::path(
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::http::api::v1::node::types::SignedHostInformation;
|
||||
use crate::http::api::{FormattedResponse, OutputParams};
|
||||
use axum::extract::Query;
|
||||
use nym_node_requests::api::v1::node::models::SignedHostInformation;
|
||||
|
||||
/// Returns host information of this node.
|
||||
#[utoipa::path(
|
||||
|
||||
@@ -4,16 +4,14 @@
|
||||
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::roles::roles;
|
||||
use crate::http::api::v1::node::types::{NodeRoles, SignedHostInformation};
|
||||
use crate::http::state::AppState;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
use nym_bin_common::build_information::BinaryBuildInformationOwned;
|
||||
use nym_node_requests::api::v1::node::models;
|
||||
|
||||
pub mod build_information;
|
||||
pub mod host_information;
|
||||
pub mod roles;
|
||||
pub mod types;
|
||||
|
||||
pub(crate) mod routes {
|
||||
pub(crate) const ROLES: &str = "/roles";
|
||||
@@ -23,9 +21,9 @@ pub(crate) mod routes {
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Config {
|
||||
pub build_information: BinaryBuildInformationOwned,
|
||||
pub host_information: SignedHostInformation,
|
||||
pub roles: NodeRoles,
|
||||
pub build_information: models::BinaryBuildInformationOwned,
|
||||
pub host_information: models::SignedHostInformation,
|
||||
pub roles: models::NodeRoles,
|
||||
}
|
||||
|
||||
pub(super) fn routes(config: Config) -> Router<AppState> {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::http::api::v1::node::types::NodeRoles;
|
||||
use crate::http::router::api::{FormattedResponse, OutputParams};
|
||||
use axum::extract::Query;
|
||||
use nym_node_requests::api::v1::node::models::NodeRoles;
|
||||
|
||||
/// Returns roles supported by this node
|
||||
#[utoipa::path(
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
use crate::http::router::api;
|
||||
use crate::http::state::AppState;
|
||||
use axum::Router;
|
||||
use nym_node_requests::api as api_requests;
|
||||
use utoipa::OpenApi;
|
||||
use utoipa_swagger_ui::SwaggerUi;
|
||||
|
||||
@@ -24,17 +25,17 @@ use utoipa_swagger_ui::SwaggerUi;
|
||||
components(schemas(
|
||||
api::Output,
|
||||
api::OutputParams,
|
||||
api::v1::node::types::BinaryBuildInformationOwned,
|
||||
api::v1::node::types::SignedHostInformation,
|
||||
api::v1::node::types::HostInformation,
|
||||
api::v1::node::types::HostKeys,
|
||||
api::v1::node::types::NodeRoles,
|
||||
api::v1::gateway::types::Gateway,
|
||||
api::v1::gateway::types::Wireguard,
|
||||
api::v1::gateway::types::ClientInterfaces,
|
||||
api::v1::gateway::types::WebSockets,
|
||||
api::v1::mixnode::types::Mixnode,
|
||||
api::v1::network_requester::types::NetworkRequester,
|
||||
api_requests::v1::node::models::BinaryBuildInformationOwned,
|
||||
api_requests::v1::node::models::SignedHostInformation,
|
||||
api_requests::v1::node::models::HostInformation,
|
||||
api_requests::v1::node::models::HostKeys,
|
||||
api_requests::v1::node::models::NodeRoles,
|
||||
api_requests::v1::gateway::models::Gateway,
|
||||
api_requests::v1::gateway::models::Wireguard,
|
||||
api_requests::v1::gateway::models::ClientInterfaces,
|
||||
api_requests::v1::gateway::models::WebSockets,
|
||||
api_requests::v1::mixnode::models::Mixnode,
|
||||
api_requests::v1::network_requester::models::NetworkRequester,
|
||||
))
|
||||
)]
|
||||
pub(crate) struct ApiDoc;
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::error::NymNodeError;
|
||||
use crate::http::api::v1::gateway::types::Gateway;
|
||||
use crate::http::api::v1::mixnode::types::Mixnode;
|
||||
use crate::http::api::v1::network_requester::types::NetworkRequester;
|
||||
use crate::http::api::v1::node::types::SignedHostInformation;
|
||||
use crate::http::middleware::logging;
|
||||
use crate::http::state::AppState;
|
||||
use crate::http::NymNodeHTTPServer;
|
||||
use axum::Router;
|
||||
use nym_bin_common::build_information::BinaryBuildInformationOwned;
|
||||
use nym_node_requests::api::v1::gateway::models::Gateway;
|
||||
use nym_node_requests::api::v1::mixnode::models::Mixnode;
|
||||
use nym_node_requests::api::v1::network_requester::models::NetworkRequester;
|
||||
use nym_node_requests::api::v1::node::models;
|
||||
use nym_node_requests::api::SignedHostInformation;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
pub mod api;
|
||||
@@ -33,7 +33,7 @@ pub struct Config {
|
||||
|
||||
impl Config {
|
||||
pub fn new(
|
||||
build_information: BinaryBuildInformationOwned,
|
||||
build_information: models::BinaryBuildInformationOwned,
|
||||
host_information: SignedHostInformation,
|
||||
) -> Self {
|
||||
Config {
|
||||
|
||||
Reference in New Issue
Block a user