connect: expose tauri get_config_file_location (#1413)

* connect: expose get_config_file_location

* rustfmt
This commit is contained in:
Jon Häggblad
2022-06-28 17:11:03 +02:00
committed by GitHub
parent 6c9c961152
commit 3e2c54c283
2 changed files with 20 additions and 1 deletions
+19 -1
View File
@@ -1,3 +1,5 @@
use std::path::PathBuf;
use client_core::config::GatewayEndpoint;
use log::info;
@@ -17,6 +19,14 @@ const DEFAULT_ETH_ENDPOINT: &str = "https://rinkeby.infura.io/v3/000000000000000
const DEFAULT_ETH_PRIVATE_KEY: &str =
"0000000000000000000000000000000000000000000000000000000000000001";
#[tauri::command]
pub fn get_config_file_location() -> String {
let id: &str = SOCKS5_CONFIG_ID;
Config::config_file_location(id)
.to_string_lossy()
.to_string()
}
pub struct Config {
socks5: Socks5Config,
}
@@ -51,6 +61,10 @@ impl Config {
init_socks5(service_provider, None).await;
info!("Configuration saved 🚀");
}
pub fn config_file_location(id: &str) -> PathBuf {
Socks5Config::default_config_file_path(Some(id))
}
}
pub async fn init_socks5(provider_address: &str, chosen_gateway_id: Option<&str>) {
@@ -58,7 +72,11 @@ pub async fn init_socks5(provider_address: &str, chosen_gateway_id: Option<&str>
let id: &str = SOCKS5_CONFIG_ID;
let already_init = Socks5Config::default_config_file_path(Some(id)).exists();
log::debug!(
"Attempting to use config file location: {}",
Config::config_file_location(id).to_string_lossy(),
);
let already_init = Config::config_file_location(id).exists();
if already_init {
log::info!(
"SOCKS5 client \"{}\" was already initialised before! \
+1
View File
@@ -34,6 +34,7 @@ fn main() {
tauri::Builder::default()
.manage(Arc::new(RwLock::new(State::new())))
.invoke_handler(tauri::generate_handler![
crate::config::get_config_file_location,
crate::operations::connection::connect::get_service_provider,
crate::operations::connection::connect::set_service_provider,
crate::operations::connection::connect::start_connecting,