-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3846 from nymtech/jon/handle-unable-upgrade-config
clients: handle config upgrade failure
- Loading branch information
Showing
12 changed files
with
101 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
// Copyright 2023 - Nym Technologies SA <[email protected]> | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::client::config::persistence::ClientPaths; | ||
use crate::client::config::{default_config_filepath, Config, Socket, SocketType}; | ||
use crate::{ | ||
client::config::{ | ||
default_config_filepath, persistence::ClientPaths, Config, Socket, SocketType, | ||
}, | ||
error::ClientError, | ||
}; | ||
|
||
use nym_bin_common::logging::LoggingSettings; | ||
use nym_client_core::config::disk_persistence::old_v1_1_20_2::CommonClientPathsV1_1_20_2; | ||
use nym_client_core::config::old_config_v1_1_20_2::ConfigV1_1_20_2 as BaseConfigV1_1_20_2; | ||
|
@@ -43,18 +48,18 @@ impl ConfigV1_1_20_2 { | |
|
||
// in this upgrade, gateway endpoint configuration was moved out of the config file, | ||
// so its returned to be stored elsewhere. | ||
pub fn upgrade(self) -> (Config, GatewayEndpointConfig) { | ||
pub fn upgrade(self) -> Result<(Config, GatewayEndpointConfig), ClientError> { | ||
let gateway_details = self.base.client.gateway_endpoint.clone().into(); | ||
let config = Config { | ||
base: self.base.into(), | ||
socket: self.socket.into(), | ||
storage_paths: ClientPaths { | ||
common_paths: self.storage_paths.common_paths.upgrade_default(), | ||
common_paths: self.storage_paths.common_paths.upgrade_default()?, | ||
}, | ||
logging: self.logging, | ||
}; | ||
|
||
(config, gateway_details) | ||
Ok((config, gateway_details)) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
// Copyright 2023 - Nym Technologies SA <[email protected]> | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::config::persistence::SocksClientPaths; | ||
use crate::config::{default_config_filepath, Config}; | ||
use crate::{ | ||
config::{default_config_filepath, persistence::SocksClientPaths, Config}, | ||
error::Socks5ClientError, | ||
}; | ||
|
||
use nym_bin_common::logging::LoggingSettings; | ||
use nym_client_core::config::disk_persistence::old_v1_1_20_2::CommonClientPathsV1_1_20_2; | ||
use nym_client_core::config::GatewayEndpointConfig; | ||
use nym_config::read_config_from_toml_file; | ||
pub use nym_socks5_client_core::config::old_config_v1_1_20_2::ConfigV1_1_20_2 as CoreConfigV1_1_20_2; | ||
use serde::{Deserialize, Serialize}; | ||
use std::io; | ||
use std::path::Path; | ||
|
||
pub use nym_socks5_client_core::config::old_config_v1_1_20_2::ConfigV1_1_20_2 as CoreConfigV1_1_20_2; | ||
|
||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize, Clone)] | ||
pub struct SocksClientPathsV1_1_20_2 { | ||
#[serde(flatten)] | ||
|
@@ -39,16 +43,16 @@ impl ConfigV1_1_20_2 { | |
|
||
// in this upgrade, gateway endpoint configuration was moved out of the config file, | ||
// so its returned to be stored elsewhere. | ||
pub fn upgrade(self) -> (Config, GatewayEndpointConfig) { | ||
pub fn upgrade(self) -> Result<(Config, GatewayEndpointConfig), Socks5ClientError> { | ||
let gateway_details = self.core.base.client.gateway_endpoint.clone().into(); | ||
let config = Config { | ||
core: self.core.into(), | ||
storage_paths: SocksClientPaths { | ||
common_paths: self.storage_paths.common_paths.upgrade_default(), | ||
common_paths: self.storage_paths.common_paths.upgrade_default()?, | ||
}, | ||
logging: self.logging, | ||
}; | ||
|
||
(config, gateway_details) | ||
Ok((config, gateway_details)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
// Copyright 2023 - Nym Technologies SA <[email protected]> | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::config::persistence::NetworkRequesterPaths; | ||
use crate::config::{default_config_filepath, Config, Debug, NetworkRequester}; | ||
use crate::{ | ||
config::{ | ||
default_config_filepath, persistence::NetworkRequesterPaths, Config, Debug, | ||
NetworkRequester, | ||
}, | ||
error::NetworkRequesterError, | ||
}; | ||
|
||
use log::trace; | ||
use nym_bin_common::logging::LoggingSettings; | ||
use nym_client_core::config::disk_persistence::old_v1_1_20_2::CommonClientPathsV1_1_20_2; | ||
|
@@ -58,7 +64,7 @@ impl ConfigV1_1_20_2 { | |
|
||
// in this upgrade, gateway endpoint configuration was moved out of the config file, | ||
// so its returned to be stored elsewhere. | ||
pub fn upgrade(self) -> (Config, GatewayEndpointConfig) { | ||
pub fn upgrade(self) -> Result<(Config, GatewayEndpointConfig), NetworkRequesterError> { | ||
trace!("Upgrading from v1.1.20_2"); | ||
let gateway_details = self.base.client.gateway_endpoint.clone().into(); | ||
let nr_description = self | ||
|
@@ -72,7 +78,7 @@ impl ConfigV1_1_20_2 { | |
let config = Config { | ||
base: self.base.into(), | ||
storage_paths: NetworkRequesterPaths { | ||
common_paths: self.storage_paths.common_paths.upgrade_default(), | ||
common_paths: self.storage_paths.common_paths.upgrade_default()?, | ||
allowed_list_location: self.storage_paths.allowed_list_location, | ||
unknown_list_location: self.storage_paths.unknown_list_location, | ||
nr_description, | ||
|
@@ -82,7 +88,7 @@ impl ConfigV1_1_20_2 { | |
network_requester: self.network_requester.into(), | ||
}; | ||
|
||
(config, gateway_details) | ||
Ok((config, gateway_details)) | ||
} | ||
} | ||
|
||
|