114d92f93f
* changed NymConfigTemplate trait to call 'template' by reference * network requester lib * introduced generic parameter to 'MixTrafficController' to allow non-remote gateways * allowing for custom gateway sender * types cleanup * minor gateway cmds refactor + initial NR work * wip * running a NR inside gateway note: this NR isnt tied to the gateway yet * rebase fixes * propagating same shutdown handle * wip * starting NR with appropriate local transceiver * fixed premature shutdown * wiring up PacketRouter * both ends wired together * actually working so much cleanup to do now * started removing dead code * wip * temp: hardcode gateway * further cleanup * fixed build of other binaries * setup-network-requester subcmd * overriding NR config in gateway init/run * wip making it wasm-compatible [again] * refactored 'GatewaySetup' * clippy and friends * removed debug code * rust 1.72 lints * ensuring local gateway is available + some comments * correctly putting network requester data in the same underlying details struct * improved gateway errors * changed 'network_requester_config' deserialization * missing clap annotation for 'enabled' flag in 'setup-network-requester' command * saving config file after 'setup-network-requester' * removed dead code * review comments * make embedded NR wait for gateway to come online (for at most 70min) * fixed shutdown on successful gateway wait * updated NR config override
77 lines
1.9 KiB
Rust
77 lines
1.9 KiB
Rust
// Copyright 2020-2023 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
#![warn(clippy::expect_used)]
|
|
#![warn(clippy::unwrap_used)]
|
|
|
|
use clap::{crate_name, crate_version, Parser};
|
|
use colored::Colorize;
|
|
use lazy_static::lazy_static;
|
|
use log::error;
|
|
use nym_bin_common::bin_info;
|
|
use nym_bin_common::logging::{maybe_print_banner, setup_logging};
|
|
use nym_bin_common::output_format::OutputFormat;
|
|
use nym_network_defaults::setup_env;
|
|
use std::error::Error;
|
|
|
|
mod commands;
|
|
mod config;
|
|
pub(crate) mod error;
|
|
mod node;
|
|
pub(crate) mod support;
|
|
|
|
lazy_static! {
|
|
pub static ref PRETTY_BUILD_INFORMATION: String = bin_info!().pretty_print();
|
|
}
|
|
|
|
// Helper for passing LONG_VERSION to clap
|
|
fn pretty_build_info_static() -> &'static str {
|
|
&PRETTY_BUILD_INFORMATION
|
|
}
|
|
|
|
#[derive(Parser)]
|
|
#[clap(author = "Nymtech", version, about, long_version = pretty_build_info_static())]
|
|
struct Cli {
|
|
/// Path pointing to an env file that configures the gateway.
|
|
#[clap(short, long)]
|
|
pub(crate) config_env_file: Option<std::path::PathBuf>,
|
|
|
|
/// Flag used for disabling the printed banner in tty.
|
|
#[clap(long)]
|
|
pub(crate) no_banner: bool,
|
|
|
|
#[clap(subcommand)]
|
|
command: commands::Commands,
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
|
|
let args = Cli::parse();
|
|
setup_env(args.config_env_file.as_ref());
|
|
|
|
if !args.no_banner {
|
|
maybe_print_banner(crate_name!(), crate_version!());
|
|
}
|
|
setup_logging();
|
|
|
|
commands::execute(args).await.map_err(|err| {
|
|
if atty::is(atty::Stream::Stdout) {
|
|
let error_message = format!("{err}").red();
|
|
error!("{error_message}");
|
|
error!("Exiting...");
|
|
}
|
|
err
|
|
})
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use clap::CommandFactory;
|
|
|
|
#[test]
|
|
fn verify_cli() {
|
|
Cli::command().debug_assert();
|
|
}
|
|
}
|