diff --git a/Cargo.lock b/Cargo.lock index 081887a..f6343ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "acme-client" -version = "1.1.1" +version = "1.2.0" dependencies = [ "acme-lib", "aliyun-openapi-core-rust-sdk", diff --git a/Cargo.toml b/Cargo.toml index d568699..3923059 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "acme-client" -version = "1.1.1" +version = "1.2.0" authors = ["Hatter Jiang "] edition = "2018" description = "Acme auto challenge client, acme-client can issue certificates from Let's encrypt" diff --git a/src/acme.rs b/src/acme.rs index c60656e..cbacbd4 100644 --- a/src/acme.rs +++ b/src/acme.rs @@ -141,6 +141,7 @@ pub fn request_acme_certificate(acme_request: AcmeRequest, dns_cleaned_domains: let mut line = String::new(); information!("You need to config dns manually, press enter to continue..."); let _ = std::io::stdin().read_line(&mut line).unwrap(); + information!("Continued") } else { return simple_error!("Interact is not allowed, --allow-interact to allow interact"); } diff --git a/src/main.rs b/src/main.rs index bd4578a..63c471a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,7 +44,6 @@ async fn main() -> tide::Result<()> { .author(AUTHORS) .arg(Arg::with_name("version").short("V").long("version").help("Print version")) .arg(Arg::with_name("verbose").short("v").long("verbose").help("Verbose")) - .arg(Arg::with_name("type").short("t").long("type").default_value("http").takes_value(true).help("Type http or dns")) .arg(Arg::with_name("port").short("p").long("port").default_value("80").takes_value(true).help("Http port")) .arg(Arg::with_name("domain").short("d").long("domain").multiple(true).takes_value(true).help("Domains")) .arg(Arg::with_name("email").long("email").takes_value(true).help("Contract email")) @@ -59,9 +58,10 @@ async fn main() -> tide::Result<()> { .arg(Arg::with_name("hide-logo").long("hide-logo").help("Hide logo")) .arg(Arg::with_name("skip-verify-ip").short("k").long("skip-verify-ip").help("Skip verify public ip")) .arg(Arg::with_name("skip-verify-certificate").short("K").long("skip-verify-certificate").help("Skip verify certificate")) + .arg(Arg::with_name("skip-listen").long("skip-listen").help("Skip http challenge listen")) .arg(Arg::with_name("allow-interact").long("allow-interact").help("Allow interact")) - .arg(Arg::with_name("challenge-type").short("T").long("challenge-type").takes_value(true).default_value("http").help("Challenge type, http or dns")) - .arg(Arg::with_name("dns-supplier").short("s").long("dns-supplier").takes_value(true).default_value("account://***:****@**?id=*").help("DNS supplier")) + .arg(Arg::with_name("challenge-type").short("t").long("challenge-type").takes_value(true).default_value("http").help("Challenge type, http or dns")) + .arg(Arg::with_name("dns-supplier").short("s").long("dns-supplier").takes_value(true).help("DNS supplier, e.g. account://***:****@**?id=*")) .get_matches(); if matches.is_present("verbose") { @@ -127,13 +127,6 @@ async fn main() -> tide::Result<()> { email.to_string() }; - match matches.value_of("type") { - Some("http") => {} - _ => { - failure!("Type is not assigned or must be http."); - exit(1); - } - } let port: u16 = match matches.value_of("port") { Some(p) => p.parse().unwrap_or_else(|e| { failure!("Parse port: {}, failed: {}", p, e); @@ -181,11 +174,13 @@ async fn main() -> tide::Result<()> { 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 skip_listen = matches.is_present("skip-listen"); + let port = iff!(skip_listen, 0, cert_config.as_ref().map(|c| c.port).flatten().unwrap_or(port)); - if !check { + let check_config = matches.is_present("check"); + + if !check_config && port > 0 { let (s, r) = channel::bounded(1); startup_http_server(s, port); r.recv().await.ok(); @@ -195,7 +190,7 @@ async fn main() -> tide::Result<()> { let mut dns_cleaned_domains: Vec = vec![]; match cert_config { None => { // cert config is not assigned - if check { + if check_config { failure!("Bad argument `--check`"); exit(1); } @@ -221,7 +216,7 @@ async fn main() -> tide::Result<()> { let acme_request = AcmeRequest { challenge: AcmeChallenge::from_str(matches.value_of("challenge-type")), credential_supplier: matches.value_of("dns-supplier"), - allow_interact: false, + allow_interact: matches.is_present("allow-interact"), contract_email: &email, primary_name, alt_names: &alt_names, @@ -241,7 +236,7 @@ async fn main() -> tide::Result<()> { } } Some(cert_config) => { // cert config is assigned - if check { + if check_config { check_cert_config(&cert_config); return Ok(()); }