Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 952831a821 | |||
| edfa874a11 | |||
| 166c592766 |
@@ -88,16 +88,28 @@ impl<T> Config<T> {
|
|||||||
where
|
where
|
||||||
T: NymConfig,
|
T: NymConfig,
|
||||||
{
|
{
|
||||||
let id = id.into();
|
self.client.id = id.into();
|
||||||
|
self.set_empty_fields_to_defaults();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_empty_fields_to_defaults(&mut self) -> bool
|
||||||
|
where
|
||||||
|
T: NymConfig,
|
||||||
|
{
|
||||||
|
let id = &self.client.id;
|
||||||
|
let mut changes_made = false;
|
||||||
|
|
||||||
// identity key setting
|
// identity key setting
|
||||||
if self.client.private_identity_key_file.as_os_str().is_empty() {
|
if self.client.private_identity_key_file.as_os_str().is_empty() {
|
||||||
|
changes_made = true;
|
||||||
self.client.private_identity_key_file =
|
self.client.private_identity_key_file =
|
||||||
self::Client::<T>::default_private_identity_key_file(&id);
|
self::Client::<T>::default_private_identity_key_file(id);
|
||||||
}
|
}
|
||||||
if self.client.public_identity_key_file.as_os_str().is_empty() {
|
if self.client.public_identity_key_file.as_os_str().is_empty() {
|
||||||
|
changes_made = true;
|
||||||
self.client.public_identity_key_file =
|
self.client.public_identity_key_file =
|
||||||
self::Client::<T>::default_public_identity_key_file(&id);
|
self::Client::<T>::default_public_identity_key_file(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// encryption key setting
|
// encryption key setting
|
||||||
@@ -107,8 +119,9 @@ impl<T> Config<T> {
|
|||||||
.as_os_str()
|
.as_os_str()
|
||||||
.is_empty()
|
.is_empty()
|
||||||
{
|
{
|
||||||
|
changes_made = true;
|
||||||
self.client.private_encryption_key_file =
|
self.client.private_encryption_key_file =
|
||||||
self::Client::<T>::default_private_encryption_key_file(&id);
|
self::Client::<T>::default_private_encryption_key_file(id);
|
||||||
}
|
}
|
||||||
if self
|
if self
|
||||||
.client
|
.client
|
||||||
@@ -116,32 +129,35 @@ impl<T> Config<T> {
|
|||||||
.as_os_str()
|
.as_os_str()
|
||||||
.is_empty()
|
.is_empty()
|
||||||
{
|
{
|
||||||
|
changes_made = true;
|
||||||
self.client.public_encryption_key_file =
|
self.client.public_encryption_key_file =
|
||||||
self::Client::<T>::default_public_encryption_key_file(&id);
|
self::Client::<T>::default_public_encryption_key_file(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// shared gateway key setting
|
// shared gateway key setting
|
||||||
if self.client.gateway_shared_key_file.as_os_str().is_empty() {
|
if self.client.gateway_shared_key_file.as_os_str().is_empty() {
|
||||||
|
changes_made = true;
|
||||||
self.client.gateway_shared_key_file =
|
self.client.gateway_shared_key_file =
|
||||||
self::Client::<T>::default_gateway_shared_key_file(&id);
|
self::Client::<T>::default_gateway_shared_key_file(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ack key setting
|
// ack key setting
|
||||||
if self.client.ack_key_file.as_os_str().is_empty() {
|
if self.client.ack_key_file.as_os_str().is_empty() {
|
||||||
self.client.ack_key_file = self::Client::<T>::default_ack_key_file(&id);
|
changes_made = true;
|
||||||
|
self.client.ack_key_file = self::Client::<T>::default_ack_key_file(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.client.reply_surb_database_path.as_os_str().is_empty() {
|
if self.client.reply_surb_database_path.as_os_str().is_empty() {
|
||||||
|
changes_made = true;
|
||||||
self.client.reply_surb_database_path =
|
self.client.reply_surb_database_path =
|
||||||
self::Client::<T>::default_reply_surb_database_path(&id);
|
self::Client::<T>::default_reply_surb_database_path(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.client.database_path.as_os_str().is_empty() {
|
if self.client.database_path.as_os_str().is_empty() {
|
||||||
self.client.database_path = self::Client::<T>::default_database_path(&id);
|
changes_made = true;
|
||||||
|
self.client.database_path = self::Client::<T>::default_database_path(id);
|
||||||
}
|
}
|
||||||
|
changes_made
|
||||||
self.client.id = id;
|
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_disabled_credentials(&mut self, disabled_credentials_mode: bool) {
|
pub fn with_disabled_credentials(&mut self, disabled_credentials_mode: bool) {
|
||||||
@@ -439,6 +455,10 @@ pub struct Client<T> {
|
|||||||
database_path: PathBuf,
|
database_path: PathBuf,
|
||||||
|
|
||||||
/// Path to the persistent store for received reply surbs, unused encryption keys and used sender tags.
|
/// Path to the persistent store for received reply surbs, unused encryption keys and used sender tags.
|
||||||
|
// this was set to use #[serde(default)] for the purposes of compatibility for multi-surbs introduced in 1.1.4.
|
||||||
|
// if you're reading this message and we have already introduced some breaking changes, feel free
|
||||||
|
// to remove that attribute since at this point the client configs should have gotten regenerated
|
||||||
|
#[serde(default)]
|
||||||
reply_surb_database_path: PathBuf,
|
reply_surb_database_path: PathBuf,
|
||||||
|
|
||||||
/// nym_home_directory specifies absolute path to the home nym Clients directory.
|
/// nym_home_directory specifies absolute path to the home nym Clients directory.
|
||||||
|
|||||||
@@ -105,6 +105,10 @@ pub(crate) async fn execute(args: &Run) -> Result<(), Box<dyn Error + Send + Syn
|
|||||||
let override_config_fields = OverrideConfig::from(args.clone());
|
let override_config_fields = OverrideConfig::from(args.clone());
|
||||||
config = override_config(config, override_config_fields);
|
config = override_config(config, override_config_fields);
|
||||||
|
|
||||||
|
if config.get_base_mut().set_empty_fields_to_defaults() {
|
||||||
|
warn!("some of the core config options were left unset. the default values are going to get used instead.");
|
||||||
|
}
|
||||||
|
|
||||||
if !version_check(&config) {
|
if !version_check(&config) {
|
||||||
error!("failed the local version check");
|
error!("failed the local version check");
|
||||||
return Err(Box::new(ClientError::FailedLocalVersionCheck));
|
return Err(Box::new(ClientError::FailedLocalVersionCheck));
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ pub struct Socks5 {
|
|||||||
/// slower and consume nearly double the bandwidth as it will require sending reply SURBs.
|
/// slower and consume nearly double the bandwidth as it will require sending reply SURBs.
|
||||||
///
|
///
|
||||||
/// Note that some service providers might not support this.
|
/// Note that some service providers might not support this.
|
||||||
|
#[serde(default)]
|
||||||
send_anonymously: bool,
|
send_anonymously: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,6 +120,10 @@ pub(crate) async fn execute(args: &Run) -> Result<(), Box<dyn std::error::Error
|
|||||||
let override_config_fields = OverrideConfig::from(args.clone());
|
let override_config_fields = OverrideConfig::from(args.clone());
|
||||||
config = override_config(config, override_config_fields);
|
config = override_config(config, override_config_fields);
|
||||||
|
|
||||||
|
if config.get_base_mut().set_empty_fields_to_defaults() {
|
||||||
|
warn!("some of the core config options were left unset. the default values are going to get used instead.");
|
||||||
|
}
|
||||||
|
|
||||||
if !version_check(&config) {
|
if !version_check(&config) {
|
||||||
error!("failed the local version check");
|
error!("failed the local version check");
|
||||||
return Err(Box::new(Socks5ClientError::FailedLocalVersionCheck));
|
return Err(Box::new(Socks5ClientError::FailedLocalVersionCheck));
|
||||||
|
|||||||
Reference in New Issue
Block a user