Files
nym/nym-node/src/node/description.rs
T
Jędrzej Stuczyński 5a07b73375 feature: hopefully final steps of the smoosh™️ (#5201)
* removed mnemonic from gateway config struct

scaffolding for common mixnet listener

running verloc unconditionally in a nym-node

remove filtering by mixnode

extracted verloc to separate crate

integrated nym-node-http-server more tightly with the binary

most logic for handling forward packets

running all mixnode-related tasks natively inside nymnode

removed gateway storage trait in favour of the only concrete implementation

most logic for handling final hop packets

using nym-node owned socket listener for gateways

utility for sending plain message through mixnet + gateway fix

using common packet forwarding in both modes

nifying nym-node metrics

reproduce behaviour of the console logger

cleaned up cli args

redesigned gateway tasks startup procedure

removing dead code

scaffolding for old config v6

config migration

implemented MixnetMetricsCleaner

* clippy

* require entry/exit for wireguard

* removed dead code in migration code

* updated config template

* use custom user agent for verloc queries

* fixed premature shutdown of gateway tasks

* hidden nym-api flag to allow illegal node ips

* experiment: final hop handing with wireguard

* added additional startup logs

* typo

* fixed legacy stats endpoint data

* additional logs

* apply review comments

* fixed local testnet manager
2024-12-05 17:21:36 +00:00

41 lines
1.3 KiB
Rust

// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: GPL-3.0-only
use crate::error::NymNodeError;
use nym_node_requests::api::v1::node::models::NodeDescription;
use std::fs;
use std::fs::create_dir_all;
use std::path::Path;
pub fn load_node_description<P: AsRef<Path>>(path: P) -> Result<NodeDescription, NymNodeError> {
let raw = fs::read_to_string(path.as_ref()).map_err(|source| {
NymNodeError::DescriptionLoadFailure {
path: path.as_ref().to_path_buf(),
source,
}
})?;
toml::from_str(&raw).map_err(|source| NymNodeError::MalformedDescriptionFile { source })
}
pub fn save_node_description<P: AsRef<Path>>(
path: P,
description: &NodeDescription,
) -> Result<(), NymNodeError> {
// SAFETY:
// the unwrap is fine as our description format can be serialised as toml
#[allow(clippy::unwrap_used)]
let serialised = toml::to_string_pretty(description).unwrap();
if let Some(parent) = path.as_ref().parent() {
create_dir_all(parent).map_err(|source| NymNodeError::DescriptionSaveFailure {
path: path.as_ref().to_path_buf(),
source,
})?
}
fs::write(path.as_ref(), serialised).map_err(|source| NymNodeError::DescriptionSaveFailure {
path: path.as_ref().to_path_buf(),
source,
})
}