feat: add acme statics
This commit is contained in:
@@ -6,6 +6,7 @@ extern crate rust_util;
|
||||
mod config;
|
||||
mod x509;
|
||||
mod network;
|
||||
mod statics;
|
||||
// mod simple_thread_pool;
|
||||
|
||||
use std::env;
|
||||
@@ -29,6 +30,7 @@ use crate::config::{CertConfig, CERT_NAME, KEY_NAME};
|
||||
use crate::x509::{X509PublicKeyAlgo, X509EcPublicKeyAlgo};
|
||||
use std::path::PathBuf;
|
||||
use crate::network::{get_local_public_ip, get_resolver, resolve_first_ipv4};
|
||||
use crate::statics::{AcmeStatics, AcmeStatus};
|
||||
|
||||
const NAME: &str = env!("CARGO_PKG_NAME");
|
||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
@@ -251,6 +253,7 @@ async fn main() -> tide::Result<()> {
|
||||
check_cert_config(&cert_config);
|
||||
return Ok(());
|
||||
}
|
||||
let mut acme_statics = AcmeStatics::start();
|
||||
let filtered_cert_config = cert_config.filter_cert_config_items(30);
|
||||
for item in &filtered_cert_config.cert_items {
|
||||
if item.common_name.as_ref().map(|n| n.contains('*')).unwrap_or(false)
|
||||
@@ -275,9 +278,14 @@ async fn main() -> tide::Result<()> {
|
||||
};
|
||||
if let Err(e) = request_acme_certificate(acme_request) {
|
||||
failure!("Request certificate: {}, by acme failed: {}", item.path, e);
|
||||
acme_statics.add_item(dns_names.clone(), AcmeStatus::Fail(format!("{}", e)));
|
||||
} else {
|
||||
acme_statics.add_item(dns_names.clone(), AcmeStatus::Success);
|
||||
}
|
||||
}
|
||||
}
|
||||
acme_statics.end();
|
||||
success!("Statics: \n{}", acme_statics);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user