Feature/config refactor (#3498)

* revamping mixnode connfig

* wip

* native client config revamping

* wip

* building socks5

* using const for mixnnode config template

* compiling updated gateway

* nym-api

* nym-sdk

* everything compiling once more

but definitely not compatible with CI and older versions (yet)

* creating full directory structure on init

* renamed paths to storage_paths and fixed mixnode template

* mixnode config migration

* gateway config migration

* nym-api config migration

* native client config migration

* socks5 client config migration

* NR config migration

* removed deprecations (that will be resolved in the following PRs) + fixed clippy

* nym-connect clippy

* nym-connect config updates

* outfox fixes

* defined socks5 lib config

* clippy

* fixed wasm client build

* removed explicit packet_type argument when starting base client

it's known implicitly from the previously passed config struct

* Empty commit

* fixed re-using gateway information when client configs are re-initialised

* fixed borrowing id value in nym-connect

* post-rebase fixes

* updated 'old_config' versions

---------

Co-authored-by: Tommy Verrall <tommy@nymtech.net>
This commit is contained in:
Jędrzej Stuczyński
2023-06-07 17:06:35 +01:00
committed by GitHub
parent bc5198768e
commit 9a68702d4d
146 changed files with 6320 additions and 4865 deletions
+14 -14
View File
@@ -1,10 +1,8 @@
use serde::Deserialize;
use serde::Serialize;
use std::path::PathBuf;
use std::path::Path;
use std::{fs, io};
pub(crate) const DESCRIPTION_FILE: &str = "description.toml";
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
pub struct NodeDescription {
pub(crate) name: String,
@@ -25,24 +23,26 @@ impl Default for NodeDescription {
}
impl NodeDescription {
pub(crate) fn load_from_file(config_path: PathBuf) -> io::Result<NodeDescription> {
let description_file_path: PathBuf = [config_path.to_str().unwrap(), DESCRIPTION_FILE]
.iter()
.collect();
let toml = fs::read_to_string(description_file_path)?;
pub(crate) fn load_from_file<P: AsRef<Path>>(path: P) -> io::Result<NodeDescription> {
// let description_file_path: PathBuf = [config_path.to_str().unwrap(), DESCRIPTION_FILE]
// .iter()
// .collect();
// let toml = fs::read_to_string(description_file_path)?;
// toml::from_str(&toml).map_err(|toml_err| io::Error::new(io::ErrorKind::Other, toml_err))
let toml = fs::read_to_string(path)?;
toml::from_str(&toml).map_err(|toml_err| io::Error::new(io::ErrorKind::Other, toml_err))
}
pub(crate) fn save_to_file(
pub(crate) fn save_to_file<P: AsRef<Path>>(
description: &NodeDescription,
config_path: PathBuf,
path: P,
) -> io::Result<()> {
let description_file_path: PathBuf = [config_path.to_str().unwrap(), DESCRIPTION_FILE]
.iter()
.collect();
// let description_file_path: PathBuf = [config_path.to_str().unwrap(), DESCRIPTION_FILE]
// .iter()
// .collect();
let description_toml =
toml::to_string(description).expect("could not encode description to toml");
fs::write(description_file_path, description_toml)?;
fs::write(path, description_toml)?;
Ok(())
}
}