From 937becb1acb31be10cb69c1934ffa7ffcb36c2c5 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Tue, 4 Feb 2020 13:11:37 +0000 Subject: [PATCH] Removed runner --- mixnode/src/node/mod.rs | 1 - mixnode/src/node/runner.rs | 85 -------------------------------------- 2 files changed, 86 deletions(-) delete mode 100644 mixnode/src/node/runner.rs diff --git a/mixnode/src/node/mod.rs b/mixnode/src/node/mod.rs index b9085f4c48..c590081f13 100644 --- a/mixnode/src/node/mod.rs +++ b/mixnode/src/node/mod.rs @@ -17,7 +17,6 @@ use tokio::runtime::Runtime; mod metrics; mod presence; -pub mod runner; pub struct Config { pub announce_address: String, diff --git a/mixnode/src/node/runner.rs b/mixnode/src/node/runner.rs deleted file mode 100644 index eec5496238..0000000000 --- a/mixnode/src/node/runner.rs +++ /dev/null @@ -1,85 +0,0 @@ -use crate::node; -use crate::node::MixNode; -use clap::ArgMatches; -use std::net::ToSocketAddrs; - -fn print_binding_warning(address: &str) { - println!("\n##### WARNING #####"); - println!( - "\nYou are trying to bind to {} - you might not be accessible to other nodes", - address - ); - println!("\n##### WARNING #####\n"); -} - -pub fn start(matches: &ArgMatches) { - println!("Starting mixnode..."); - - let config = new_config(matches); - println!("Public key: {}", config.public_key_string()); - println!("Directory server: {}", config.directory_server); - println!( - "Listening for incoming packets on {}", - config.socket_address - ); - println!( - "Announcing the following socket address: {}", - config.announce_address - ); - - let mix = MixNode::new(&config); - mix.start(config).unwrap(); -} - -fn new_config(matches: &ArgMatches) -> node::Config { - let host = matches.value_of("host").unwrap(); - if host == "localhost" || host == "127.0.0.1" || host == "0.0.0.0" { - print_binding_warning(host); - } - - let port = match matches.value_of("port").unwrap_or("1789").parse::() { - Ok(n) => n, - Err(err) => panic!("Invalid port value provided - {:?}", err), - }; - - let layer = match matches.value_of("layer").unwrap().parse::() { - Ok(n) => n, - Err(err) => panic!("Invalid layer value provided - {:?}", err), - }; - - let socket_address = (host, port) - .to_socket_addrs() - .expect("Failed to combine host and port") - .next() - .expect("Failed to extract the socket address from the iterator"); - - let announce_host = matches.value_of("announce_host").unwrap_or(host); - let announce_port = matches - .value_of("announce_port") - .map(|port| port.parse::().unwrap()) - .unwrap_or(port); - - let _ = (announce_host, announce_port) - .to_socket_addrs() - .expect("Failed to combine announce host and port") - .next() - .expect("Failed to extract the announce socket address from the iterator"); - - let announce_address = format!("{}:{}", announce_host, announce_port); - - let (secret_key, public_key) = sphinx::crypto::keygen(); - - let directory_server = matches - .value_of("directory") - .unwrap_or("https://directory.nymtech.net") - .to_string(); - - node::Config { - directory_server, - layer, - public_key, - socket_address, - announce_address, - secret_key, - } -}