diff --git a/mixnode/src/main.rs b/mixnode/src/main.rs index 6f92d4285c..ee05378043 100644 --- a/mixnode/src/main.rs +++ b/mixnode/src/main.rs @@ -32,6 +32,18 @@ fn main() { .takes_value(true) .required(true), ) + .arg( + Arg::with_name("announce_host") + .long("announce-host") + .help("The host that will be reported to the directory server") + .takes_value(true) + ) + .arg( + Arg::with_name("announce_port") + .long("announce-port") + .help("The port that will be reported to the directory server") + .takes_value(true) + ) .arg( Arg::with_name("directory") .long("directory") diff --git a/mixnode/src/node/mod.rs b/mixnode/src/node/mod.rs index f6e151803d..e7ac5b1c65 100644 --- a/mixnode/src/node/mod.rs +++ b/mixnode/src/node/mod.rs @@ -19,6 +19,7 @@ mod presence; pub mod runner; pub struct Config { + announce_socket_address: SocketAddr, directory_server: String, layer: usize, public_key: MontgomeryPoint, diff --git a/mixnode/src/node/presence.rs b/mixnode/src/node/presence.rs index 678d8af880..f10d697087 100644 --- a/mixnode/src/node/presence.rs +++ b/mixnode/src/node/presence.rs @@ -17,7 +17,7 @@ impl Notifier { }; let net_client = directory_client::Client::new(config); let presence = MixNodePresence { - host: node_config.socket_address.to_string(), // note: the directory server determines the real incoming IP itself, but uses the socket. Host here is just a placeholder. + host: node_config.announce_socket_address.to_string(), pub_key: node_config.public_key_string(), layer: node_config.layer as u64, last_seen: 0, diff --git a/mixnode/src/node/runner.rs b/mixnode/src/node/runner.rs index 8f120cc0a7..19640765e5 100644 --- a/mixnode/src/node/runner.rs +++ b/mixnode/src/node/runner.rs @@ -51,6 +51,18 @@ fn new_config(matches: &ArgMatches) -> node::Config { .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_socket_address = (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 (secret_key, public_key) = sphinx::crypto::keygen(); let directory_server = matches @@ -63,6 +75,7 @@ fn new_config(matches: &ArgMatches) -> node::Config { layer, public_key, socket_address, + announce_socket_address, secret_key, } }