diff --git a/clients/client-core/src/config/mod.rs b/clients/client-core/src/config/mod.rs index 30da8b2242..75acaf1d2e 100644 --- a/clients/client-core/src/config/mod.rs +++ b/clients/client-core/src/config/mod.rs @@ -26,7 +26,7 @@ pub mod persistence; pub const MISSING_VALUE: &str = "MISSING VALUE"; // 'CLIENT' -const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://directory.nymtech.net"; +pub const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://validator.nymtech.net"; // 'DEBUG' const DEFAULT_ACK_WAIT_MULTIPLIER: f64 = 1.5; @@ -176,7 +176,7 @@ impl Config { self.client.gateway_listener = gateway_listener.into(); } - pub fn with_custom_validator>(&mut self, validator: S) { + pub fn set_custom_validator>(&mut self, validator: S) { self.client.validator_rest_url = validator.into(); } @@ -335,8 +335,7 @@ pub struct Client { id: String, /// URL to the validator server for obtaining network topology. - // before 0.9.0 this was the directory server - #[serde(alias = "directory_server")] + #[serde(default = "missing_string_value")] validator_rest_url: String, /// Special mode of the system such that all messages are sent as soon as they are received diff --git a/clients/native/src/commands/mod.rs b/clients/native/src/commands/mod.rs index 848780729b..6523653c36 100644 --- a/clients/native/src/commands/mod.rs +++ b/clients/native/src/commands/mod.rs @@ -21,7 +21,7 @@ pub(crate) mod upgrade; pub(crate) fn override_config(mut config: Config, matches: &ArgMatches) -> Config { if let Some(validator) = matches.value_of("validator") { - config.get_base_mut().with_custom_validator(validator); + config.get_base_mut().set_custom_validator(validator); } if let Some(gateway_id) = matches.value_of("gateway") { diff --git a/clients/native/src/commands/upgrade.rs b/clients/native/src/commands/upgrade.rs index dca5c6038e..391d832faa 100644 --- a/clients/native/src/commands/upgrade.rs +++ b/clients/native/src/commands/upgrade.rs @@ -14,6 +14,7 @@ use crate::client::config::{Config, MISSING_VALUE}; use clap::{App, Arg, ArgMatches}; +use client_core::config::DEFAULT_VALIDATOR_REST_ENDPOINT; use config::NymConfig; use std::fmt::Display; use std::process; @@ -79,12 +80,27 @@ fn pre_090_upgrade(from: &str, mut config: Config) -> Config { Version::new(0, 9, 0) }; + if config.get_base().get_validator_rest_endpoint() != MISSING_VALUE { + eprintln!("existing config seems to have specified new validator rest endpoint which was only introduced in 0.9.0! Can't perform upgrade."); + print_failed_upgrade(&from_version, &to_version); + process::exit(1); + } + print_start_upgrade(&from_version, &to_version); config .get_base_mut() .set_custom_version(to_version.to_string().as_ref()); + println!( + "Setting validator REST endpoint to to {}", + DEFAULT_VALIDATOR_REST_ENDPOINT + ); + + config + .get_base_mut() + .set_custom_validator(DEFAULT_VALIDATOR_REST_ENDPOINT); + config.save_to_file(None).unwrap_or_else(|err| { eprintln!("failed to overwrite config file! - {:?}", err); print_failed_upgrade(&from_version, &to_version); diff --git a/clients/socks5/src/commands/mod.rs b/clients/socks5/src/commands/mod.rs index 30be2d00ba..ef75167f5b 100644 --- a/clients/socks5/src/commands/mod.rs +++ b/clients/socks5/src/commands/mod.rs @@ -21,7 +21,7 @@ pub(crate) mod upgrade; pub(crate) fn override_config(mut config: Config, matches: &ArgMatches) -> Config { if let Some(validator) = matches.value_of("validator") { - config.get_base_mut().with_custom_validator(validator); + config.get_base_mut().set_custom_validator(validator); } if let Some(gateway_id) = matches.value_of("gateway") { diff --git a/clients/socks5/src/commands/upgrade.rs b/clients/socks5/src/commands/upgrade.rs index 8415c52162..75e58790ad 100644 --- a/clients/socks5/src/commands/upgrade.rs +++ b/clients/socks5/src/commands/upgrade.rs @@ -14,6 +14,7 @@ use crate::client::config::{Config, MISSING_VALUE}; use clap::{App, Arg, ArgMatches}; +use client_core::config::DEFAULT_VALIDATOR_REST_ENDPOINT; use config::NymConfig; use std::fmt::Display; use std::process; @@ -79,12 +80,27 @@ fn pre_090_upgrade(from: &str, mut config: Config) -> Config { Version::new(0, 9, 0) }; + if config.get_base().get_validator_rest_endpoint() != MISSING_VALUE { + eprintln!("existing config seems to have specified new validator rest endpoint which was only introduced in 0.9.0! Can't perform upgrade."); + print_failed_upgrade(&from_version, &to_version); + process::exit(1); + } + print_start_upgrade(&from_version, &to_version); config .get_base_mut() .set_custom_version(to_version.to_string().as_ref()); + println!( + "Setting validator REST endpoint to to {}", + DEFAULT_VALIDATOR_REST_ENDPOINT + ); + + config + .get_base_mut() + .set_custom_validator(DEFAULT_VALIDATOR_REST_ENDPOINT); + config.save_to_file(None).unwrap_or_else(|err| { eprintln!("failed to overwrite config file! - {:?}", err); print_failed_upgrade(&from_version, &to_version); diff --git a/gateway/src/commands/upgrade.rs b/gateway/src/commands/upgrade.rs index c736eea653..bd1ab0e72b 100644 --- a/gateway/src/commands/upgrade.rs +++ b/gateway/src/commands/upgrade.rs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::config::DEFAULT_VALIDATOR_REST_ENDPOINT; use crate::config::{Config, MISSING_VALUE}; use clap::{App, Arg, ArgMatches}; use config::NymConfig; @@ -81,7 +82,20 @@ fn pre_090_upgrade(from: &str, config: Config) -> Config { print_start_upgrade(&from_version, &to_version); - let upgraded_config = config.with_custom_version(to_version.to_string().as_ref()); + if config.get_validator_rest_endpoint() != MISSING_VALUE { + eprintln!("existing config seems to have specified new validator rest endpoint which was only introduced in 0.9.0! Can't perform upgrade."); + print_failed_upgrade(&from_version, &to_version); + process::exit(1); + } + + println!( + "Setting validator REST endpoint to to {}", + DEFAULT_VALIDATOR_REST_ENDPOINT + ); + + let upgraded_config = config + .with_custom_version(to_version.to_string().as_ref()) + .with_custom_validator(DEFAULT_VALIDATOR_REST_ENDPOINT); upgraded_config.save_to_file(None).unwrap_or_else(|err| { eprintln!("failed to overwrite config file! - {:?}", err); diff --git a/gateway/src/config/mod.rs b/gateway/src/config/mod.rs index 5c1b8447a6..16c092c4ec 100644 --- a/gateway/src/config/mod.rs +++ b/gateway/src/config/mod.rs @@ -32,7 +32,7 @@ pub(crate) const MISSING_VALUE: &str = "MISSING VALUE"; // 'GATEWAY' const DEFAULT_MIX_LISTENING_PORT: u16 = 1789; const DEFAULT_CLIENT_LISTENING_PORT: u16 = 9000; -pub(crate) const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://directory.nymtech.net"; +pub(crate) const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://validator.nymtech.net"; // 'DEBUG' // where applicable, the below are defined in milliseconds @@ -494,7 +494,7 @@ pub struct Gateway { public_sphinx_key_file: PathBuf, /// Validator server to which the node will be reporting their presence data. - #[serde(alias = "presence_directory_server")] + #[serde(default = "missing_string_value")] validator_rest_url: String, /// nym_home_directory specifies absolute path to the home nym gateways directory. diff --git a/mixnode/src/commands/upgrade.rs b/mixnode/src/commands/upgrade.rs index 89c7374e8c..5666b3c0ee 100644 --- a/mixnode/src/commands/upgrade.rs +++ b/mixnode/src/commands/upgrade.rs @@ -12,7 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::config::{missing_string_value, Config, DEFAULT_METRICS_SERVER}; +use crate::config::{ + missing_string_value, Config, DEFAULT_METRICS_SERVER, DEFAULT_VALIDATOR_REST_ENDPOINT, +}; use clap::{App, Arg, ArgMatches}; use config::NymConfig; use crypto::asymmetric::identity; @@ -94,16 +96,27 @@ fn pre_090_upgrade(from: &str, config: Config) -> Config { } if config.get_metrics_server() != missing_string_value::() { - eprintln!("existing config seems to have specified new metrics-server endpoint which was only introduced in 0.9.0! Can't perform upgrade."); + eprintln!("existing config seems to have specified new metrics-server endpoint which was only introduced in 0.9.0! Can't perform upgrade."); + print_failed_upgrade(&from_version, &to_version); + process::exit(1); + } + + if config.get_validator_rest_endpoint() != missing_string_value::() { + eprintln!("existing config seems to have specified new validator rest endpoint which was only introduced in 0.9.0! Can't perform upgrade."); print_failed_upgrade(&from_version, &to_version); process::exit(1); } let mut upgraded_config = config .with_custom_version(to_version.to_string().as_ref()) - .with_custom_metrics_server(DEFAULT_METRICS_SERVER); + .with_custom_metrics_server(DEFAULT_METRICS_SERVER) + .with_custom_validator(DEFAULT_VALIDATOR_REST_ENDPOINT); println!("Setting metrics server to {}", DEFAULT_METRICS_SERVER); + println!( + "Setting validator REST endpoint to to {}", + DEFAULT_VALIDATOR_REST_ENDPOINT + ); println!("Generating new identity..."); let identity_keys = identity::KeyPair::new(); diff --git a/mixnode/src/config/mod.rs b/mixnode/src/config/mod.rs index 6996a09336..5fb44bfbb6 100644 --- a/mixnode/src/config/mod.rs +++ b/mixnode/src/config/mod.rs @@ -31,7 +31,7 @@ pub(crate) const MISSING_VALUE: &str = "MISSING VALUE"; // 'MIXNODE' const DEFAULT_LISTENING_PORT: u16 = 1789; -pub(crate) const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://directory.nymtech.net"; +pub(crate) const DEFAULT_VALIDATOR_REST_ENDPOINT: &str = "https://validator.nymtech.net"; pub(crate) const DEFAULT_METRICS_SERVER: &str = "https://metrics.nymtech.net"; // 'DEBUG' @@ -396,7 +396,7 @@ pub struct MixNode { public_sphinx_key_file: PathBuf, /// Validator server to which the node will be reporting their presence data. - #[serde(alias = "presence_directory_server")] + #[serde(default = "missing_string_value")] validator_rest_url: String, /// Metrics server to which the node will be reporting their metrics data.