Merge branch 'develop' into feature/windows_fix
This commit is contained in:
@@ -15,6 +15,12 @@ pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
|
||||
.takes_value(true)
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("location")
|
||||
.long("location")
|
||||
.help("Optional geographical location of this node")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("layer")
|
||||
.long("layer")
|
||||
|
||||
@@ -41,5 +41,9 @@ pub(crate) fn override_config(mut config: Config, matches: &ArgMatches) -> Confi
|
||||
config = config.with_announce_port(announce_port.unwrap());
|
||||
}
|
||||
|
||||
if let Some(location) = matches.value_of("location") {
|
||||
config = config.with_location(location);
|
||||
}
|
||||
|
||||
config
|
||||
}
|
||||
|
||||
@@ -15,6 +15,12 @@ pub fn command_args<'a, 'b>() -> App<'a, 'b> {
|
||||
.required(true),
|
||||
)
|
||||
// the rest of arguments are optional, they are used to override settings in config file
|
||||
.arg(
|
||||
Arg::with_name("location")
|
||||
.long("location")
|
||||
.help("Optional geographical location of this node")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("config")
|
||||
.long("config")
|
||||
|
||||
@@ -91,6 +91,11 @@ impl Config {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_location<S: Into<String>>(mut self, location: S) -> Self {
|
||||
self.mixnode.location = location.into();
|
||||
self
|
||||
}
|
||||
|
||||
// if you want to use distinct servers for metrics and presence
|
||||
// you need to do so in the config.toml file.
|
||||
pub fn with_custom_directory<S: Into<String>>(mut self, directory_server: S) -> Self {
|
||||
@@ -180,6 +185,10 @@ impl Config {
|
||||
self.config_directory().join(Self::config_file_name())
|
||||
}
|
||||
|
||||
pub fn get_location(&self) -> String {
|
||||
self.mixnode.location.clone()
|
||||
}
|
||||
|
||||
pub fn get_private_sphinx_key_file(&self) -> PathBuf {
|
||||
self.mixnode.private_sphinx_key_file.clone()
|
||||
}
|
||||
@@ -231,6 +240,12 @@ pub struct MixNode {
|
||||
/// ID specifies the human readable ID of this particular mixnode.
|
||||
id: String,
|
||||
|
||||
/// Completely optional value specifying geographical location of this particular node.
|
||||
/// Currently it's used entirely for debug purposes, as there are no mechanisms implemented
|
||||
/// to verify correctness of the information provided. However, feel free to fill in
|
||||
/// this field with as much accuracy as you wish to share.
|
||||
location: String,
|
||||
|
||||
/// Layer of this particular mixnode determining its position in the network.
|
||||
layer: u64,
|
||||
|
||||
@@ -264,12 +279,17 @@ impl MixNode {
|
||||
fn default_public_sphinx_key_file(id: &str) -> PathBuf {
|
||||
Config::default_data_directory(Some(id)).join("public_sphinx.pem")
|
||||
}
|
||||
|
||||
fn default_location() -> String {
|
||||
"unknown".into()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MixNode {
|
||||
fn default() -> Self {
|
||||
MixNode {
|
||||
id: "".to_string(),
|
||||
location: Self::default_location(),
|
||||
layer: 0,
|
||||
listening_address: format!("0.0.0.0:{}", DEFAULT_LISTENING_PORT)
|
||||
.parse()
|
||||
|
||||
@@ -13,6 +13,12 @@ pub(crate) fn config_template() -> &'static str {
|
||||
# Human readable ID of this particular mixnode.
|
||||
id = '{{ mixnode.id }}'
|
||||
|
||||
# Completely optional value specifying geographical location of this particular node.
|
||||
# Currently it's used entirely for debug purposes, as there are no mechanisms implemented
|
||||
# to verify correctness of the information provided. However, feel free to fill in
|
||||
# this field with as much accuracy as you wish to share.
|
||||
location = "{{ mixnode.location }}"
|
||||
|
||||
# Layer of this particular mixnode determining its position in the network.
|
||||
layer = {{ mixnode.layer }}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ impl MixNode {
|
||||
fn start_presence_notifier(&self) {
|
||||
info!("Starting presence notifier...");
|
||||
let notifier_config = presence::NotifierConfig::new(
|
||||
self.config.get_location(),
|
||||
self.config.get_presence_directory_server(),
|
||||
self.config.get_announce_address(),
|
||||
self.sphinx_keypair.public_key().to_base58_string(),
|
||||
|
||||
@@ -8,6 +8,7 @@ use tokio::runtime::Handle;
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
pub struct NotifierConfig {
|
||||
location: String,
|
||||
directory_server: String,
|
||||
announce_host: String,
|
||||
pub_key_string: String,
|
||||
@@ -17,6 +18,7 @@ pub struct NotifierConfig {
|
||||
|
||||
impl NotifierConfig {
|
||||
pub fn new(
|
||||
location: String,
|
||||
directory_server: String,
|
||||
announce_host: String,
|
||||
pub_key_string: String,
|
||||
@@ -24,6 +26,7 @@ impl NotifierConfig {
|
||||
sending_delay: Duration,
|
||||
) -> Self {
|
||||
NotifierConfig {
|
||||
location,
|
||||
directory_server,
|
||||
announce_host,
|
||||
pub_key_string,
|
||||
@@ -46,6 +49,7 @@ impl Notifier {
|
||||
};
|
||||
let net_client = directory_client::Client::new(directory_client_cfg);
|
||||
let presence = MixNodePresence {
|
||||
location: config.location,
|
||||
host: config.announce_host,
|
||||
pub_key: config.pub_key_string,
|
||||
layer: config.layer,
|
||||
|
||||
Reference in New Issue
Block a user