mixnode: added announce-host and announce-port arguments

This commit is contained in:
Jedrzej Stuczynski
2020-01-17 11:59:59 +00:00
parent 4cc7fc309b
commit 1769fa8a5a
4 changed files with 27 additions and 1 deletions
+12
View File
@@ -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")
+1
View File
@@ -19,6 +19,7 @@ mod presence;
pub mod runner;
pub struct Config {
announce_socket_address: SocketAddr,
directory_server: String,
layer: usize,
public_key: MontgomeryPoint,
+1 -1
View File
@@ -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,
+13
View File
@@ -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::<u16>().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,
}
}