Requiring explicit host + printing bound address on startup

This commit is contained in:
Jedrzej Stuczynski
2020-01-06 12:12:40 +00:00
parent 27c61cb194
commit efb4660fe7
+9 -10
View File
@@ -14,8 +14,10 @@ pub fn start(matches: &ArgMatches) {
let config = new_config(matches);
println!("Public key: {}", config.public_key_string());
// println!("Startup on: {}", config.socket_address);
println!("Listening for incoming packets...");
println!(
"Listening for incoming packets on {}",
config.socket_address
);
let mix = MixNode::new(&config);
thread::spawn(move || {
@@ -26,7 +28,7 @@ pub fn start(matches: &ArgMatches) {
}
fn new_config(matches: &ArgMatches) -> node::Config {
let host = matches.value_of("host").unwrap_or("0.0.0.0");
let host = matches.value_of("host").unwrap();
let port = match matches.value_of("port").unwrap_or("1789").parse::<u16>() {
Ok(n) => n,
@@ -38,8 +40,6 @@ fn new_config(matches: &ArgMatches) -> node::Config {
Err(err) => panic!("Invalid layer value provided - {:?}", err),
};
let is_local = matches.is_present("local");
let socket_address = (host, port)
.to_socket_addrs()
.expect("Failed to combine host and port")
@@ -48,11 +48,10 @@ fn new_config(matches: &ArgMatches) -> node::Config {
let (secret_key, public_key) = sphinx::crypto::keygen();
let directory_server = if is_local {
"http://localhost:8080".to_string()
} else {
"https://directory.nymtech.net".to_string()
};
let directory_server = matches
.value_of("directory")
.unwrap_or("https://directory.nymtech.net")
.to_string();
node::Config {
directory_server,