feat: add port for cert config
This commit is contained in:
@@ -53,6 +53,7 @@ pub struct CertConfigItem {
|
|||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct CertConfig {
|
pub struct CertConfig {
|
||||||
|
pub port: Option<u16>,
|
||||||
pub cert_items: Vec<CertConfigItem>,
|
pub cert_items: Vec<CertConfigItem>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +94,7 @@ impl CertConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Self { cert_items: filtered_cert_items }
|
Self { port: self.port, cert_items: filtered_cert_items }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load(config_fn: &str) -> XResult<Self> {
|
pub fn load(config_fn: &str) -> XResult<Self> {
|
||||||
|
|||||||
15
src/main.rs
15
src/main.rs
@@ -186,6 +186,14 @@ async fn main() -> tide::Result<()> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let cert_config_file = matches.value_of("config");
|
||||||
|
let cert_config = cert_config_file.map(|f|
|
||||||
|
CertConfig::load(f).unwrap_or_else(|e| {
|
||||||
|
failure!("Load cert config: {}, failed: {}", f, e);
|
||||||
|
exit(1);
|
||||||
|
}));
|
||||||
|
let port = cert_config.as_ref().map(|c| c.port).flatten().unwrap_or(port);
|
||||||
|
|
||||||
let check = matches.is_present("check");
|
let check = matches.is_present("check");
|
||||||
|
|
||||||
if !check {
|
if !check {
|
||||||
@@ -195,7 +203,6 @@ async fn main() -> tide::Result<()> {
|
|||||||
task::sleep(Duration::from_millis(500)).await;
|
task::sleep(Duration::from_millis(500)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cert_config = matches.value_of("config");
|
|
||||||
match cert_config {
|
match cert_config {
|
||||||
None => { // cert config is not assigned
|
None => { // cert config is not assigned
|
||||||
if check {
|
if check {
|
||||||
@@ -240,12 +247,6 @@ async fn main() -> tide::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(cert_config) => { // cert config is assigned
|
Some(cert_config) => { // cert config is assigned
|
||||||
let cert_config = {
|
|
||||||
CertConfig::load(cert_config).unwrap_or_else(|e| {
|
|
||||||
failure!("Load cert config: {}, failed: {}", cert_config, e);
|
|
||||||
exit(1);
|
|
||||||
})
|
|
||||||
};
|
|
||||||
if check {
|
if check {
|
||||||
check_cert_config(&cert_config);
|
check_cert_config(&cert_config);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|||||||
Reference in New Issue
Block a user