|
|
|
@ -5,8 +5,8 @@ use futures::stream::StreamExt; |
|
|
|
|
use signal_hook_tokio::Signals; |
|
|
|
|
|
|
|
|
|
use std::net::SocketAddr; |
|
|
|
|
use std::path; |
|
|
|
|
use std::str::FromStr; |
|
|
|
|
use std::{path, sync}; |
|
|
|
|
|
|
|
|
|
#[derive(Parser, Debug)] |
|
|
|
|
#[command(version)] |
|
|
|
@ -60,12 +60,6 @@ struct Cli { |
|
|
|
|
domain_acme_contact_email: Option<String>, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Clone)] |
|
|
|
|
struct HTTPSParams { |
|
|
|
|
https_listen_addr: SocketAddr, |
|
|
|
|
domain_acme_manager: sync::Arc<dyn domiply::domain::acme::manager::Manager>, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[tokio::main] |
|
|
|
|
async fn main() { |
|
|
|
|
let config = Cli::parse(); |
|
|
|
@ -92,7 +86,7 @@ async fn main() { |
|
|
|
|
let domain_config_store = domiply::domain::config::new(&config.domain_config_store_dir_path) |
|
|
|
|
.expect("domain config store initialization failed"); |
|
|
|
|
|
|
|
|
|
let https_params = if let Some(https_listen_addr) = config.https_listen_addr { |
|
|
|
|
let domain_acme_manager = if config.https_listen_addr.is_some() { |
|
|
|
|
let domain_acme_store_dir_path = config.domain_acme_store_dir_path.unwrap(); |
|
|
|
|
|
|
|
|
|
let domain_acme_store = domiply::domain::acme::store::new(&domain_acme_store_dir_path) |
|
|
|
@ -102,15 +96,11 @@ async fn main() { |
|
|
|
|
// settings.
|
|
|
|
|
let domain_acme_contact_email = config.domain_acme_contact_email.unwrap(); |
|
|
|
|
|
|
|
|
|
let domain_acme_manager = |
|
|
|
|
Some( |
|
|
|
|
domiply::domain::acme::manager::new(domain_acme_store, &domain_acme_contact_email) |
|
|
|
|
.await |
|
|
|
|
.expect("domain acme manager initialization failed"); |
|
|
|
|
|
|
|
|
|
Some(HTTPSParams { |
|
|
|
|
https_listen_addr, |
|
|
|
|
domain_acme_manager, |
|
|
|
|
}) |
|
|
|
|
.expect("domain acme manager initialization failed"), |
|
|
|
|
) |
|
|
|
|
} else { |
|
|
|
|
None |
|
|
|
|
}; |
|
|
|
@ -122,7 +112,7 @@ async fn main() { |
|
|
|
|
origin_store, |
|
|
|
|
domain_config_store, |
|
|
|
|
domain_checker, |
|
|
|
|
https_params.as_ref().map(|p| p.domain_acme_manager.clone()), |
|
|
|
|
domain_acme_manager, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
let _ = domiply::service::http::new( |
|
|
|
@ -132,10 +122,12 @@ async fn main() { |
|
|
|
|
config.passphrase, |
|
|
|
|
config.http_listen_addr.clone(), |
|
|
|
|
config.http_domain.clone(), |
|
|
|
|
https_params.map(|p| domiply::service::http::HTTPSParams { |
|
|
|
|
listen_addr: p.https_listen_addr, |
|
|
|
|
cert_resolver: domain_manager.clone(), |
|
|
|
|
}), |
|
|
|
|
config |
|
|
|
|
.https_listen_addr |
|
|
|
|
.map(|listen_addr| domiply::service::http::HTTPSParams { |
|
|
|
|
listen_addr, |
|
|
|
|
cert_resolver: domain_manager.clone(), |
|
|
|
|
}), |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
let mut signals = |
|
|
|
|