Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4077bfa060 | |||
| f60aa8a1ca |
+1
-1
@@ -20,7 +20,7 @@ rust-version = "1.58.1"
|
|||||||
axum = { workspace = true }
|
axum = { workspace = true }
|
||||||
anyhow = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
bs58 = { workspace = true }
|
bs58 = { workspace = true }
|
||||||
clap = { workspace = true, features = ["cargo", "derive"] }
|
clap = { workspace = true, features = ["cargo", "derive", "env"] }
|
||||||
colored = "2.0"
|
colored = "2.0"
|
||||||
cupid = "0.6.1"
|
cupid = "0.6.1"
|
||||||
dirs = "4.0"
|
dirs = "4.0"
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
use crate::env::vars::*;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use nym_bin_common::bin_info_owned;
|
use nym_bin_common::bin_info_owned;
|
||||||
use nym_bin_common::output_format::OutputFormat;
|
use nym_bin_common::output_format::OutputFormat;
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
pub(crate) struct BuildInfo {
|
pub(crate) struct BuildInfo {
|
||||||
#[clap(short, long, default_value_t = OutputFormat::default())]
|
#[clap(short, long, default_value_t = OutputFormat::default(), env = MIXNODE_OUTPUT_ARG)]
|
||||||
output: OutputFormat,
|
output: OutputFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
// Copyright 2021-2023 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021-2023 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
use super::DEFAULT_MIXNODE_ID;
|
||||||
use crate::commands::try_load_current_config;
|
use crate::commands::try_load_current_config;
|
||||||
|
use crate::env::vars::*;
|
||||||
use crate::node::node_description::NodeDescription;
|
use crate::node::node_description::NodeDescription;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
@@ -11,7 +13,7 @@ use std::io::Write;
|
|||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
pub(crate) struct Describe {
|
pub(crate) struct Describe {
|
||||||
/// The id of the mixnode you want to describe
|
/// The id of the mixnode you want to describe
|
||||||
#[clap(long)]
|
#[clap(long, default_value = DEFAULT_MIXNODE_ID, env = MIXNODE_ID_ARG)]
|
||||||
id: String,
|
id: String,
|
||||||
|
|
||||||
/// Human readable name of this node
|
/// Human readable name of this node
|
||||||
|
|||||||
@@ -1,46 +1,52 @@
|
|||||||
// Copyright 2020-2023 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2020-2024 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use super::OverrideConfig;
|
use super::OverrideConfig;
|
||||||
|
use super::DEFAULT_MIXNODE_ID;
|
||||||
use crate::commands::override_config;
|
use crate::commands::override_config;
|
||||||
use crate::config::{
|
use crate::config::{
|
||||||
default_config_directory, default_config_filepath, default_data_directory, Config,
|
default_config_directory, default_config_filepath, default_data_directory, Config,
|
||||||
};
|
};
|
||||||
|
use crate::env::vars::*;
|
||||||
use crate::node::MixNode;
|
use crate::node::MixNode;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use nym_bin_common::output_format::OutputFormat;
|
use nym_bin_common::output_format::OutputFormat;
|
||||||
|
use nym_config::defaults::{
|
||||||
|
DEFAULT_HTTP_API_LISTENING_PORT, DEFAULT_MIX_LISTENING_PORT, DEFAULT_VERLOC_LISTENING_PORT,
|
||||||
|
};
|
||||||
|
use nym_config::helpers::inaddr_any;
|
||||||
use nym_crypto::asymmetric::{encryption, identity};
|
use nym_crypto::asymmetric::{encryption, identity};
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
use std::{fs, io};
|
use std::{fs, io};
|
||||||
|
|
||||||
#[derive(Args, Clone)]
|
#[derive(Args, Clone, Debug)]
|
||||||
pub(crate) struct Init {
|
pub(crate) struct Init {
|
||||||
/// Id of the mixnode we want to create config for
|
/// Id of the mixnode we want to create config for
|
||||||
#[clap(long)]
|
#[clap(long, default_value = DEFAULT_MIXNODE_ID, env = MIXNODE_ID_ARG)]
|
||||||
id: String,
|
id: String,
|
||||||
|
|
||||||
/// The host on which the mixnode will be running
|
/// The host on which the mixnode will be running
|
||||||
#[clap(long)]
|
#[clap(long, alias = "host", default_value_t = inaddr_any(), env = MIXNODE_LISTENING_ADDRESS_ARG)]
|
||||||
host: IpAddr,
|
listening_address: IpAddr,
|
||||||
|
|
||||||
/// The port on which the mixnode will be listening for mix packets
|
/// The port on which the mixnode will be listening for mix packets
|
||||||
#[clap(long)]
|
#[clap(long, default_value_t = DEFAULT_MIX_LISTENING_PORT, env = MIXNODE_MIX_PORT_ARG)]
|
||||||
mix_port: Option<u16>,
|
mix_port: u16,
|
||||||
|
|
||||||
/// The port on which the mixnode will be listening for verloc packets
|
/// The port on which the mixnode will be listening for verloc packets
|
||||||
#[clap(long)]
|
#[clap(long, default_value_t = DEFAULT_VERLOC_LISTENING_PORT, env = MIXNODE_VERLOC_PORT_ARG)]
|
||||||
verloc_port: Option<u16>,
|
verloc_port: u16,
|
||||||
|
|
||||||
/// The port on which the mixnode will be listening for http requests
|
/// The port on which the mixnode will be listening for http requests
|
||||||
#[clap(long)]
|
#[clap(long, default_value_t = DEFAULT_HTTP_API_LISTENING_PORT, env = MIXNODE_HTTP_API_PORT_ARG)]
|
||||||
http_api_port: Option<u16>,
|
http_api_port: u16,
|
||||||
|
|
||||||
/// Comma separated list of nym-api endpoints of the validators
|
/// Comma separated list of nym-api endpoints of the validators
|
||||||
// the alias here is included for backwards compatibility (1.1.4 and before)
|
// the alias here is included for backwards compatibility (1.1.4 and before)
|
||||||
#[clap(long, alias = "validators", value_delimiter = ',')]
|
#[clap(long, alias = "validators", value_delimiter = ',', env = MIXNODE_NYM_APIS_ARG)]
|
||||||
nym_apis: Option<Vec<url::Url>>,
|
nym_apis: Option<Vec<url::Url>>,
|
||||||
|
|
||||||
#[clap(short, long, default_value_t = OutputFormat::default())]
|
#[clap(short, long, default_value_t = OutputFormat::default(), env = MIXNODE_OUTPUT_ARG)]
|
||||||
output: OutputFormat,
|
output: OutputFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,10 +54,10 @@ impl From<Init> for OverrideConfig {
|
|||||||
fn from(init_config: Init) -> Self {
|
fn from(init_config: Init) -> Self {
|
||||||
OverrideConfig {
|
OverrideConfig {
|
||||||
id: init_config.id,
|
id: init_config.id,
|
||||||
host: Some(init_config.host),
|
listening_address: Some(init_config.listening_address),
|
||||||
mix_port: init_config.mix_port,
|
mix_port: Some(init_config.mix_port),
|
||||||
verloc_port: init_config.verloc_port,
|
verloc_port: Some(init_config.verloc_port),
|
||||||
http_api_port: init_config.http_api_port,
|
http_api_port: Some(init_config.http_api_port),
|
||||||
nym_apis: init_config.nym_apis,
|
nym_apis: init_config.nym_apis,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ use nym_crypto::bech32_address_validation;
|
|||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
|
pub const DEFAULT_MIXNODE_ID: &str = "nym-mixnode";
|
||||||
|
|
||||||
mod build_info;
|
mod build_info;
|
||||||
mod describe;
|
mod describe;
|
||||||
mod init;
|
mod init;
|
||||||
@@ -54,7 +56,7 @@ pub(crate) enum Commands {
|
|||||||
// Configuration that can be overridden.
|
// Configuration that can be overridden.
|
||||||
struct OverrideConfig {
|
struct OverrideConfig {
|
||||||
id: String,
|
id: String,
|
||||||
host: Option<IpAddr>,
|
listening_address: Option<IpAddr>,
|
||||||
mix_port: Option<u16>,
|
mix_port: Option<u16>,
|
||||||
verloc_port: Option<u16>,
|
verloc_port: Option<u16>,
|
||||||
http_api_port: Option<u16>,
|
http_api_port: Option<u16>,
|
||||||
@@ -79,7 +81,7 @@ pub(crate) async fn execute(args: Cli) -> anyhow::Result<()> {
|
|||||||
|
|
||||||
fn override_config(config: Config, args: OverrideConfig) -> Config {
|
fn override_config(config: Config, args: OverrideConfig) -> Config {
|
||||||
config
|
config
|
||||||
.with_optional(Config::with_listening_address, args.host)
|
.with_optional(Config::with_listening_address, args.listening_address)
|
||||||
.with_optional(Config::with_mix_port, args.mix_port)
|
.with_optional(Config::with_mix_port, args.mix_port)
|
||||||
.with_optional(Config::with_verloc_port, args.verloc_port)
|
.with_optional(Config::with_verloc_port, args.verloc_port)
|
||||||
.with_optional(Config::with_http_api_port, args.http_api_port)
|
.with_optional(Config::with_http_api_port, args.http_api_port)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021-2024 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
use super::DEFAULT_MIXNODE_ID;
|
||||||
use crate::commands::try_load_current_config;
|
use crate::commands::try_load_current_config;
|
||||||
|
use crate::env::vars::*;
|
||||||
use crate::node::MixNode;
|
use crate::node::MixNode;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use nym_bin_common::output_format::OutputFormat;
|
use nym_bin_common::output_format::OutputFormat;
|
||||||
@@ -9,7 +11,7 @@ use nym_bin_common::output_format::OutputFormat;
|
|||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
pub(crate) struct NodeDetails {
|
pub(crate) struct NodeDetails {
|
||||||
/// The id of the mixnode you want to show details for
|
/// The id of the mixnode you want to show details for
|
||||||
#[clap(long)]
|
#[clap(long, default_value = DEFAULT_MIXNODE_ID, env = MIXNODE_ID_ARG)]
|
||||||
id: String,
|
id: String,
|
||||||
|
|
||||||
#[clap(short, long, default_value_t = OutputFormat::default())]
|
#[clap(short, long, default_value_t = OutputFormat::default())]
|
||||||
|
|||||||
+12
-14
@@ -2,47 +2,45 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use super::OverrideConfig;
|
use super::OverrideConfig;
|
||||||
|
use super::DEFAULT_MIXNODE_ID;
|
||||||
use crate::commands::{override_config, try_load_current_config, version_check};
|
use crate::commands::{override_config, try_load_current_config, version_check};
|
||||||
|
use crate::env::vars::*;
|
||||||
use crate::node::MixNode;
|
use crate::node::MixNode;
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use log::error;
|
use log::error;
|
||||||
use nym_bin_common::output_format::OutputFormat;
|
use nym_bin_common::output_format::OutputFormat;
|
||||||
use nym_config::helpers::SPECIAL_ADDRESSES;
|
use nym_config::helpers::SPECIAL_ADDRESSES;
|
||||||
use nym_validator_client::nyxd;
|
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
|
|
||||||
#[derive(Args, Clone)]
|
#[derive(Args, Clone)]
|
||||||
pub(crate) struct Run {
|
pub(crate) struct Run {
|
||||||
/// Id of the nym-mixnode we want to run
|
/// Id of the nym-mixnode we want to run
|
||||||
#[clap(long)]
|
#[clap(long, default_value = DEFAULT_MIXNODE_ID, env = MIXNODE_ID_ARG)]
|
||||||
id: String,
|
id: String,
|
||||||
|
|
||||||
/// The custom host on which the mixnode will be running
|
/// The custom host on which the mixnode will be running
|
||||||
#[clap(long)]
|
#[clap(long, alias = "host", env = MIXNODE_LISTENING_ADDRESS_ARG)]
|
||||||
host: Option<IpAddr>,
|
listening_address: Option<IpAddr>,
|
||||||
|
|
||||||
/// The wallet address you will use to bond this mixnode, e.g. nymt1z9egw0knv47nmur0p8vk4rcx59h9gg4zuxrrr9
|
|
||||||
#[clap(long)]
|
|
||||||
wallet_address: Option<nyxd::AccountId>,
|
|
||||||
|
|
||||||
/// The port on which the mixnode will be listening for mix packets
|
/// The port on which the mixnode will be listening for mix packets
|
||||||
#[clap(long)]
|
#[clap(long, env = MIXNODE_MIX_PORT_ARG)]
|
||||||
mix_port: Option<u16>,
|
mix_port: Option<u16>,
|
||||||
|
|
||||||
/// The port on which the mixnode will be listening for verloc packets
|
/// The port on which the mixnode will be listening for verloc packets
|
||||||
#[clap(long)]
|
#[clap(long, env = MIXNODE_VERLOC_PORT_ARG)]
|
||||||
verloc_port: Option<u16>,
|
verloc_port: Option<u16>,
|
||||||
|
|
||||||
/// The port on which the mixnode will be listening for http requests
|
/// The port on which the mixnode will be listening for http requests
|
||||||
#[clap(long)]
|
#[clap(long, env = MIXNODE_HTTP_API_PORT_ARG)]
|
||||||
http_api_port: Option<u16>,
|
http_api_port: Option<u16>,
|
||||||
|
|
||||||
/// Comma separated list of nym-api endpoints of the validators
|
/// Comma separated list of nym-api endpoints of the validators
|
||||||
// the alias here is included for backwards compatibility (1.1.4 and before)
|
// the alias here is included for backwards compatibility (1.1.4 and before)
|
||||||
#[clap(long, alias = "validators", value_delimiter = ',')]
|
#[clap(long, alias = "validators", value_delimiter = ',', env = MIXNODE_NYM_APIS_ARG)]
|
||||||
nym_apis: Option<Vec<url::Url>>,
|
nym_apis: Option<Vec<url::Url>>,
|
||||||
|
|
||||||
#[clap(short, long, default_value_t = OutputFormat::default())]
|
#[clap(short, long, default_value_t = OutputFormat::default(), env = MIXNODE_OUTPUT_ARG)]
|
||||||
output: OutputFormat,
|
output: OutputFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +48,7 @@ impl From<Run> for OverrideConfig {
|
|||||||
fn from(run_config: Run) -> Self {
|
fn from(run_config: Run) -> Self {
|
||||||
OverrideConfig {
|
OverrideConfig {
|
||||||
id: run_config.id,
|
id: run_config.id,
|
||||||
host: run_config.host,
|
listening_address: run_config.listening_address,
|
||||||
mix_port: run_config.mix_port,
|
mix_port: run_config.mix_port,
|
||||||
verloc_port: run_config.verloc_port,
|
verloc_port: run_config.verloc_port,
|
||||||
http_api_port: run_config.http_api_port,
|
http_api_port: run_config.http_api_port,
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
// Copyright 2020-2023 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2020-2023 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
use super::version_check;
|
||||||
|
use super::DEFAULT_MIXNODE_ID;
|
||||||
use crate::commands::{try_load_current_config, validate_bech32_address_or_exit};
|
use crate::commands::{try_load_current_config, validate_bech32_address_or_exit};
|
||||||
|
use crate::env::vars::*;
|
||||||
use crate::node::helpers::load_identity_keys;
|
use crate::node::helpers::load_identity_keys;
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use clap::{ArgGroup, Args};
|
use clap::{ArgGroup, Args};
|
||||||
@@ -12,13 +15,11 @@ use nym_types::helpers::ConsoleSigningOutput;
|
|||||||
use nym_validator_client::nyxd;
|
use nym_validator_client::nyxd;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
use super::version_check;
|
|
||||||
|
|
||||||
#[derive(Args, Clone)]
|
#[derive(Args, Clone)]
|
||||||
#[clap(group(ArgGroup::new("sign").required(true).args(&["wallet_address", "text", "contract_msg"])))]
|
#[clap(group(ArgGroup::new("sign").required(true).args(&["wallet_address", "text", "contract_msg"])))]
|
||||||
pub(crate) struct Sign {
|
pub(crate) struct Sign {
|
||||||
/// The id of the mixnode you want to sign with
|
/// The id of the mixnode you want to sign with
|
||||||
#[clap(long)]
|
#[clap(long, default_value = DEFAULT_MIXNODE_ID, env = MIXNODE_ID_ARG)]
|
||||||
id: String,
|
id: String,
|
||||||
|
|
||||||
/// Signs your blockchain address with your identity key
|
/// Signs your blockchain address with your identity key
|
||||||
@@ -34,7 +35,7 @@ pub(crate) struct Sign {
|
|||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
contract_msg: Option<String>,
|
contract_msg: Option<String>,
|
||||||
|
|
||||||
#[clap(short, long, default_value_t = OutputFormat::default())]
|
#[clap(short, long, default_value_t = OutputFormat::default(), env = MIXNODE_OUTPUT_ARG)]
|
||||||
output: OutputFormat,
|
output: OutputFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
pub mod vars {
|
||||||
|
pub const MIXNODE_ID_ARG: &str = "NYM_MIXNODE_ID";
|
||||||
|
pub const MIXNODE_LISTENING_ADDRESS_ARG: &str = "NYM_MIXNODE_LISTENING_ADDRESS";
|
||||||
|
pub const MIXNODE_MIX_PORT_ARG: &str = "NYM_MIXNODE_MIX_PORT";
|
||||||
|
pub const MIXNODE_VERLOC_PORT_ARG: &str = "NYM_MIXNODE_VERLOC_PORT";
|
||||||
|
pub const MIXNODE_HTTP_API_PORT_ARG: &str = "NYM_MIXNODE_HTTP_API_PORT";
|
||||||
|
pub const MIXNODE_NYM_APIS_ARG: &str = "NYM_MIXNODE_NYM_APIS";
|
||||||
|
pub const MIXNODE_OUTPUT_ARG: &str = "NYM_MIXNODE_OUTPUT";
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ use tracing::instrument;
|
|||||||
|
|
||||||
mod commands;
|
mod commands;
|
||||||
mod config;
|
mod config;
|
||||||
|
mod env;
|
||||||
pub(crate) mod error;
|
pub(crate) mod error;
|
||||||
mod node;
|
mod node;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user