mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
created gatewayd.toml
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
//use crate::serial::{deserialize, serialize, Decodable, Encodable};
|
||||
//use toml::{map::Map, Value};
|
||||
//use crate::util::join_config_path;
|
||||
use crate::util::join_config_path;
|
||||
//use crate::Result;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
//use log::*;
|
||||
|
||||
//use std::{fs::OpenOptions, io::prelude::*, path::PathBuf};
|
||||
use std::{fs::OpenOptions, io::prelude::*, path::PathBuf};
|
||||
|
||||
//pub trait ClientCliConfig<'a>: Default + Deserialize<'a> {
|
||||
//pub trait ClientConfig: Default + Deserialize {
|
||||
// fn load(path: PathBuf) -> Result<Self> {
|
||||
// let path = join_config_path(&path)?;
|
||||
// let mut file = OpenOptions::new()
|
||||
@@ -33,16 +34,16 @@ use serde::{Deserialize, Serialize};
|
||||
// }
|
||||
// }
|
||||
// fn save(&self, path: PathBuf) -> Result<()> {
|
||||
// let path = join_config_path(&path)?;
|
||||
// let mut file = OpenOptions::new().write(true).create(true).open(&path)?;
|
||||
// //let path = join_config_path(&path)?;
|
||||
// //let mut file = OpenOptions::new().write(true).create(true).open(&path)?;
|
||||
// //let serialized = serialize(self);
|
||||
// //file.write_all(&serialized)?;
|
||||
// Ok(())
|
||||
// }
|
||||
//}
|
||||
|
||||
//impl ClientCliConfig<'_> for DrkCliConfig {}
|
||||
//impl ClientCliConfig<'_> for DarkfidCliConfig {}
|
||||
//
|
||||
//impl ClientConfig for DrkConfig {}
|
||||
//impl ClientConfig for DarkfidConfig {}
|
||||
|
||||
#[derive(Serialize, Default, Deserialize, Debug)]
|
||||
pub struct DrkConfig {
|
||||
@@ -74,6 +75,22 @@ pub struct DarkfidConfig {
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Serialize, Default, Deserialize, Debug)]
|
||||
pub struct GatewaydConfig {
|
||||
#[serde(rename = "connect_url")]
|
||||
pub accept_url: String,
|
||||
|
||||
#[serde(rename = "subscriber_url")]
|
||||
pub publisher_url: String,
|
||||
|
||||
#[serde(rename = "database_path")]
|
||||
pub database_path: String,
|
||||
|
||||
#[serde(rename = "log_path")]
|
||||
pub log_path: String,
|
||||
}
|
||||
|
||||
//impl Default for DrkCliConfig {
|
||||
// // default toml file
|
||||
// fn default() -> Self {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
pub mod client_cli;
|
||||
pub mod service_cli;
|
||||
|
||||
pub use client_cli::cli_config::{DarkfidConfig, DrkConfig};
|
||||
pub use client_cli::cli_config::{DarkfidConfig, GatewaydConfig, DrkConfig};
|
||||
pub use client_cli::{darkfid_cli::DarkfidCli, drk_cli::DrkCli, drk_cli::Transfer};
|
||||
pub use service_cli::ServiceCli;
|
||||
|
||||
@@ -2,11 +2,11 @@ use crate::Result;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
pub struct ServiceCli {
|
||||
pub accept_addr: Option<SocketAddr>,
|
||||
pub pub_addr: Option<SocketAddr>,
|
||||
//pub accept_addr: Option<SocketAddr>,
|
||||
//pub pub_addr: Option<SocketAddr>,
|
||||
pub verbose: bool,
|
||||
pub database_path: Box<std::path::PathBuf>,
|
||||
pub log_path: Box<std::path::PathBuf>,
|
||||
//pub database_path: Box<std::path::PathBuf>,
|
||||
//pub log_path: Box<std::path::PathBuf>,
|
||||
}
|
||||
|
||||
impl ServiceCli {
|
||||
@@ -15,52 +15,52 @@ impl ServiceCli {
|
||||
(version: "0.1.0")
|
||||
(author: "Amir Taaki <amir@dyne.org>")
|
||||
(about: "run service daemon")
|
||||
(@arg ACCEPT: -a --accept +takes_value "Accept add//ress")
|
||||
(@arg PUB_ADDR: -p --pubaddr +takes_value "Publisher addr")
|
||||
//(@arg ACCEPT: -a --accept +takes_value "Accept add//ress")
|
||||
//(@arg PUB_ADDR: -p --pubaddr +takes_value "Publisher addr")
|
||||
(@arg VERBOSE: -v --verbose "Increase verbosity")
|
||||
(@arg DATABASE_PATH: --database +takes_value "database path")
|
||||
(@arg LOG_PATH: --log +takes_value "Logfile path")
|
||||
//(@arg DATABASE_PATH: --database +takes_value "database path")
|
||||
//(@arg LOG_PATH: --log +takes_value "Logfile path")
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
let accept_addr = if let Some(accept_addr) = app.value_of("ACCEPT") {
|
||||
Some(accept_addr.parse()?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
//let accept_addr = if let Some(accept_addr) = app.value_of("ACCEPT") {
|
||||
// Some(accept_addr.parse()?)
|
||||
//} else {
|
||||
// None
|
||||
//};
|
||||
|
||||
let pub_addr = if let Some(pub_addr) = app.value_of("PUB_ADDR") {
|
||||
Some(pub_addr.parse()?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
//let pub_addr = if let Some(pub_addr) = app.value_of("PUB_ADDR") {
|
||||
// Some(pub_addr.parse()?)
|
||||
//} else {
|
||||
// None
|
||||
//};
|
||||
|
||||
let verbose = app.is_present("VERBOSE");
|
||||
|
||||
let database_path = Box::new(
|
||||
if let Some(database_path) = app.value_of("DATABASE_PATH") {
|
||||
std::path::Path::new(database_path)
|
||||
} else {
|
||||
std::path::Path::new("database.db")
|
||||
}
|
||||
.to_path_buf(),
|
||||
);
|
||||
//let database_path = Box::new(
|
||||
// if let Some(database_path) = app.value_of("DATABASE_PATH") {
|
||||
// std::path::Path::new(database_path)
|
||||
// } else {
|
||||
// std::path::Path::new("database.db")
|
||||
// }
|
||||
// .to_path_buf(),
|
||||
//);
|
||||
|
||||
let log_path = Box::new(
|
||||
if let Some(log_path) = app.value_of("LOG_PATH") {
|
||||
std::path::Path::new(log_path)
|
||||
} else {
|
||||
std::path::Path::new("/tmp/darkfid_service_daemon.log")
|
||||
}
|
||||
.to_path_buf(),
|
||||
);
|
||||
//let log_path = Box::new(
|
||||
// if let Some(log_path) = app.value_of("LOG_PATH") {
|
||||
// std::path::Path::new(log_path)
|
||||
// } else {
|
||||
// std::path::Path::new("/tmp/darkfid_service_daemon.log")
|
||||
// }
|
||||
// .to_path_buf(),
|
||||
//);
|
||||
|
||||
Ok(Self {
|
||||
accept_addr,
|
||||
pub_addr,
|
||||
//accept_addr,
|
||||
//pub_addr,
|
||||
verbose,
|
||||
database_path,
|
||||
log_path,
|
||||
//database_path,
|
||||
//log_path,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user