dump config
This commit is contained in:
parent
2eb598e68c
commit
3d744fb87e
23
Cargo.lock
generated
23
Cargo.lock
generated
@ -1708,6 +1708,16 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indexmap"
|
||||||
|
version = "1.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"hashbrown",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "input_buffer"
|
name = "input_buffer"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
@ -3212,6 +3222,18 @@ dependencies = [
|
|||||||
"serde 0.8.23",
|
"serde 0.8.23",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_yaml"
|
||||||
|
version = "0.8.23"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a4a521f2940385c165a24ee286aa8599633d162077a54bdcae2a6fd5a7bfa7a0"
|
||||||
|
dependencies = [
|
||||||
|
"indexmap",
|
||||||
|
"ryu",
|
||||||
|
"serde 1.0.130",
|
||||||
|
"yaml-rust",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serial_test"
|
name = "serial_test"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
@ -3838,6 +3860,7 @@ dependencies = [
|
|||||||
"parking_lot 0.11.2",
|
"parking_lot 0.11.2",
|
||||||
"serde 1.0.130",
|
"serde 1.0.130",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
|
"serde_yaml",
|
||||||
"serial_test 0.5.1",
|
"serial_test 0.5.1",
|
||||||
"simplelog",
|
"simplelog",
|
||||||
"url",
|
"url",
|
||||||
|
@ -26,6 +26,7 @@ failure = "^0"
|
|||||||
cfg-if = "^0"
|
cfg-if = "^0"
|
||||||
serde = "^1"
|
serde = "^1"
|
||||||
serde_derive = "^1"
|
serde_derive = "^1"
|
||||||
|
serde_yaml = "^0"
|
||||||
futures = "^0"
|
futures = "^0"
|
||||||
url = "^2"
|
url = "^2"
|
||||||
ctrlc = "^3"
|
ctrlc = "^3"
|
||||||
|
@ -168,6 +168,22 @@ impl<'de> serde::Deserialize<'de> for LogLevel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl serde::Serialize for LogLevel {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: serde::Serializer,
|
||||||
|
{
|
||||||
|
let s = match self {
|
||||||
|
LogLevel::Error => "error",
|
||||||
|
LogLevel::Warn => "warn",
|
||||||
|
LogLevel::Info => "info",
|
||||||
|
LogLevel::Debug => "debug",
|
||||||
|
LogLevel::Trace => "trace",
|
||||||
|
};
|
||||||
|
s.serialize(serializer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn convert_loglevel(log_level: LogLevel) -> LevelFilter {
|
pub fn convert_loglevel(log_level: LogLevel) -> LevelFilter {
|
||||||
match log_level {
|
match log_level {
|
||||||
LogLevel::Error => LevelFilter::Error,
|
LogLevel::Error => LevelFilter::Error,
|
||||||
@ -223,6 +239,15 @@ impl<'de> serde::Deserialize<'de> for ParsedUrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl serde::Serialize for ParsedUrl {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: serde::Serializer,
|
||||||
|
{
|
||||||
|
self.urlstring.serialize(serializer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct ParsedNodeDialInfo {
|
pub struct ParsedNodeDialInfo {
|
||||||
pub node_dial_info_string: String,
|
pub node_dial_info_string: String,
|
||||||
@ -263,6 +288,15 @@ impl<'de> serde::Deserialize<'de> for ParsedNodeDialInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl serde::Serialize for ParsedNodeDialInfo {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: serde::Serializer,
|
||||||
|
{
|
||||||
|
self.node_dial_info_string.serialize(serializer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct NamedSocketAddrs {
|
pub struct NamedSocketAddrs {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
@ -290,6 +324,15 @@ impl<'de> serde::Deserialize<'de> for NamedSocketAddrs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl serde::Serialize for NamedSocketAddrs {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: serde::Serializer,
|
||||||
|
{
|
||||||
|
self.name.serialize(serializer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl NamedSocketAddrs {
|
impl NamedSocketAddrs {
|
||||||
pub fn offset_port(&mut self, offset: u16) -> Result<(), ()> {
|
pub fn offset_port(&mut self, offset: u16) -> Result<(), ()> {
|
||||||
// Bump port on name
|
// Bump port on name
|
||||||
@ -312,13 +355,13 @@ impl NamedSocketAddrs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Terminal {
|
pub struct Terminal {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub level: LogLevel,
|
pub level: LogLevel,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct File {
|
pub struct File {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub path: String,
|
pub path: String,
|
||||||
@ -326,26 +369,26 @@ pub struct File {
|
|||||||
pub level: LogLevel,
|
pub level: LogLevel,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Client {
|
pub struct Client {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub level: LogLevel,
|
pub level: LogLevel,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct ClientApi {
|
pub struct ClientApi {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub listen_address: NamedSocketAddrs,
|
pub listen_address: NamedSocketAddrs,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Logging {
|
pub struct Logging {
|
||||||
pub terminal: Terminal,
|
pub terminal: Terminal,
|
||||||
pub file: File,
|
pub file: File,
|
||||||
pub client: Client,
|
pub client: Client,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Https {
|
pub struct Https {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub listen_address: NamedSocketAddrs,
|
pub listen_address: NamedSocketAddrs,
|
||||||
@ -353,7 +396,7 @@ pub struct Https {
|
|||||||
pub url: Option<ParsedUrl>,
|
pub url: Option<ParsedUrl>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Http {
|
pub struct Http {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub listen_address: NamedSocketAddrs,
|
pub listen_address: NamedSocketAddrs,
|
||||||
@ -361,13 +404,13 @@ pub struct Http {
|
|||||||
pub url: Option<ParsedUrl>,
|
pub url: Option<ParsedUrl>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Application {
|
pub struct Application {
|
||||||
pub https: Https,
|
pub https: Https,
|
||||||
pub http: Http,
|
pub http: Http,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Udp {
|
pub struct Udp {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub socket_pool_size: u32,
|
pub socket_pool_size: u32,
|
||||||
@ -375,7 +418,7 @@ pub struct Udp {
|
|||||||
pub public_address: Option<NamedSocketAddrs>,
|
pub public_address: Option<NamedSocketAddrs>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Tcp {
|
pub struct Tcp {
|
||||||
pub connect: bool,
|
pub connect: bool,
|
||||||
pub listen: bool,
|
pub listen: bool,
|
||||||
@ -384,7 +427,7 @@ pub struct Tcp {
|
|||||||
pub public_address: Option<NamedSocketAddrs>,
|
pub public_address: Option<NamedSocketAddrs>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Ws {
|
pub struct Ws {
|
||||||
pub connect: bool,
|
pub connect: bool,
|
||||||
pub listen: bool,
|
pub listen: bool,
|
||||||
@ -394,7 +437,7 @@ pub struct Ws {
|
|||||||
pub url: Option<ParsedUrl>,
|
pub url: Option<ParsedUrl>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Wss {
|
pub struct Wss {
|
||||||
pub connect: bool,
|
pub connect: bool,
|
||||||
pub listen: bool,
|
pub listen: bool,
|
||||||
@ -404,7 +447,7 @@ pub struct Wss {
|
|||||||
pub url: Option<ParsedUrl>,
|
pub url: Option<ParsedUrl>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Protocol {
|
pub struct Protocol {
|
||||||
pub udp: Udp,
|
pub udp: Udp,
|
||||||
pub tcp: Tcp,
|
pub tcp: Tcp,
|
||||||
@ -412,14 +455,14 @@ pub struct Protocol {
|
|||||||
pub wss: Wss,
|
pub wss: Wss,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Tls {
|
pub struct Tls {
|
||||||
pub certificate_path: PathBuf,
|
pub certificate_path: PathBuf,
|
||||||
pub private_key_path: PathBuf,
|
pub private_key_path: PathBuf,
|
||||||
pub connection_initial_timeout: u64,
|
pub connection_initial_timeout: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Rpc {
|
pub struct Rpc {
|
||||||
pub concurrency: u32,
|
pub concurrency: u32,
|
||||||
pub queue_size: u32,
|
pub queue_size: u32,
|
||||||
@ -429,7 +472,7 @@ pub struct Rpc {
|
|||||||
pub max_route_hop_count: u8,
|
pub max_route_hop_count: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Dht {
|
pub struct Dht {
|
||||||
pub resolve_node_timeout: Option<u64>,
|
pub resolve_node_timeout: Option<u64>,
|
||||||
pub resolve_node_count: u32,
|
pub resolve_node_count: u32,
|
||||||
@ -446,7 +489,7 @@ pub struct Dht {
|
|||||||
pub validate_dial_info_receipt_time: u64,
|
pub validate_dial_info_receipt_time: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Leases {
|
pub struct Leases {
|
||||||
pub max_server_signal_leases: u32,
|
pub max_server_signal_leases: u32,
|
||||||
pub max_server_relay_leases: u32,
|
pub max_server_relay_leases: u32,
|
||||||
@ -454,7 +497,7 @@ pub struct Leases {
|
|||||||
pub max_client_relay_leases: u32,
|
pub max_client_relay_leases: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Network {
|
pub struct Network {
|
||||||
pub max_connections: u32,
|
pub max_connections: u32,
|
||||||
pub connection_initial_timeout: u64,
|
pub connection_initial_timeout: u64,
|
||||||
@ -473,23 +516,23 @@ pub struct Network {
|
|||||||
pub leases: Leases,
|
pub leases: Leases,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Testing {
|
pub struct Testing {
|
||||||
pub subnode_index: u16,
|
pub subnode_index: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct TableStore {
|
pub struct TableStore {
|
||||||
pub directory: PathBuf,
|
pub directory: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Core {
|
pub struct Core {
|
||||||
pub tablestore: TableStore,
|
pub tablestore: TableStore,
|
||||||
pub network: Network,
|
pub network: Network,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct SettingsInner {
|
pub struct SettingsInner {
|
||||||
pub daemon: bool,
|
pub daemon: bool,
|
||||||
pub client_api: ClientApi,
|
pub client_api: ClientApi,
|
||||||
|
@ -57,6 +57,11 @@ fn parse_command_line(default_config_path: &OsStr) -> Result<clap::ArgMatches, c
|
|||||||
.default_value_os(default_config_path)
|
.default_value_os(default_config_path)
|
||||||
.help("Specify a configuration file to use"),
|
.help("Specify a configuration file to use"),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("dump-config")
|
||||||
|
.long("dump-config")
|
||||||
|
.help("Instead of running the server, print the configuration it would use to the console"),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("bootstrap")
|
Arg::with_name("bootstrap")
|
||||||
.long("bootstrap")
|
.long("bootstrap")
|
||||||
@ -244,6 +249,15 @@ pub async fn main() -> Result<(), String> {
|
|||||||
clogwriter,
|
clogwriter,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Dump Config ---
|
||||||
|
if matches.occurrences_of("dump-config") != 0 {
|
||||||
|
//let cfg = config::Config::try_from(&*settingsr);
|
||||||
|
return serde_yaml::to_writer(std::io::stdout(), &*settingsr).map_err(|e| e.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Normal Startup ---
|
||||||
|
|
||||||
CombinedLogger::init(logs).map_err(|e| format!("failed to init logs: {}", e))?;
|
CombinedLogger::init(logs).map_err(|e| format!("failed to init logs: {}", e))?;
|
||||||
|
|
||||||
// Create Veilid Core
|
// Create Veilid Core
|
||||||
|
Loading…
Reference in New Issue
Block a user