chore: clean clode
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
|
use std::fs;
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::fs;
|
use acme_lib::{Directory, create_p256_key, create_p384_key, create_rsa_key};
|
||||||
use acme_lib::{create_p256_key, create_p384_key, create_rsa_key};
|
|
||||||
use acme_lib::persist::FilePersist;
|
use acme_lib::persist::FilePersist;
|
||||||
use acme_lib::Directory;
|
|
||||||
use rust_util::XResult;
|
use rust_util::XResult;
|
||||||
use aliyun_openapi_core_rust_sdk::RPClient;
|
use aliyun_openapi_core_rust_sdk::RPClient;
|
||||||
use crate::util::parse_dns_record;
|
use crate::util::parse_dns_record;
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
use std::collections::HashMap;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use rust_util::XResult;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use acme_lib::DirectoryUrl;
|
use std::collections::HashMap;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
use crate::x509;
|
use serde::{Deserialize, Serialize};
|
||||||
use crate::x509::{X509PublicKeyAlgo, X509Certificate};
|
use rust_util::XResult;
|
||||||
|
use acme_lib::DirectoryUrl;
|
||||||
|
use crate::x509::{X509PublicKeyAlgo, X509Certificate, parse_x509};
|
||||||
|
|
||||||
pub const CERT_NAME: &str = "cert.pem";
|
pub const CERT_NAME: &str = "cert.pem";
|
||||||
pub const KEY_NAME: &str = "key.pem";
|
pub const KEY_NAME: &str = "key.pem";
|
||||||
@@ -157,7 +156,7 @@ impl CertConfigItem {
|
|||||||
let cert_path_buff = path_buff.join(CERT_NAME);
|
let cert_path_buff = path_buff.join(CERT_NAME);
|
||||||
if self.common_name.is_none() && self.dns_names.is_none() {
|
if self.common_name.is_none() && self.dns_names.is_none() {
|
||||||
let pem = opt_result!(fs::read_to_string(cert_path_buff.clone()), "Read file: {:?}, failed: {}", cert_path_buff);
|
let pem = opt_result!(fs::read_to_string(cert_path_buff.clone()), "Read file: {:?}, failed: {}", cert_path_buff);
|
||||||
let x509_certificate = opt_result!(x509::parse_x509(&format!("{}/{}", self.path, CERT_NAME), &pem), "Parse x509: {}/{}, faield: {}", self.path, CERT_NAME);
|
let x509_certificate = opt_result!(parse_x509(&format!("{}/{}", self.path, CERT_NAME), &pem), "Parse x509: {}/{}, faield: {}", self.path, CERT_NAME);
|
||||||
self.common_name = Some(x509_certificate.common_name.clone());
|
self.common_name = Some(x509_certificate.common_name.clone());
|
||||||
self.dns_names = Some(x509_certificate.alt_names.clone());
|
self.dns_names = Some(x509_certificate.alt_names.clone());
|
||||||
if let Some(pos) = x509_certificate.alt_names.iter().position(|n| n == &x509_certificate.common_name) {
|
if let Some(pos) = x509_certificate.alt_names.iter().position(|n| n == &x509_certificate.common_name) {
|
||||||
@@ -185,7 +184,7 @@ impl CertConfigItem {
|
|||||||
}
|
}
|
||||||
if cert_path_buff.exists() {
|
if cert_path_buff.exists() {
|
||||||
let pem = opt_result!(fs::read_to_string(cert_path_buff.clone()), "Read file: {:?}, failed: {}", cert_path_buff);
|
let pem = opt_result!(fs::read_to_string(cert_path_buff.clone()), "Read file: {:?}, failed: {}", cert_path_buff);
|
||||||
let x509_certificate = opt_result!(x509::parse_x509(&format!("{}/{}", self.path, CERT_NAME), &pem), "Parse x509: {}/{}, faield: {}", self.path, CERT_NAME);
|
let x509_certificate = opt_result!(parse_x509(&format!("{}/{}", self.path, CERT_NAME), &pem), "Parse x509: {}/{}, faield: {}", self.path, CERT_NAME);
|
||||||
|
|
||||||
let mut self_dns_names = vec![];
|
let mut self_dns_names = vec![];
|
||||||
let mut cert_dns_names = vec![];
|
let mut cert_dns_names = vec![];
|
||||||
|
|||||||
10
src/main.rs
10
src/main.rs
@@ -13,14 +13,14 @@ mod dingtalk;
|
|||||||
mod ali_dns;
|
mod ali_dns;
|
||||||
// mod simple_thread_pool;
|
// mod simple_thread_pool;
|
||||||
|
|
||||||
use std::env;
|
|
||||||
use clap::{App, Arg};
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::str::FromStr;
|
use std::env;
|
||||||
use tide::Request;
|
use std::path::PathBuf;
|
||||||
use std::process::{Command, exit};
|
use std::process::{Command, exit};
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
use std::path::PathBuf;
|
use std::str::FromStr;
|
||||||
|
use tide::Request;
|
||||||
|
use clap::{App, Arg};
|
||||||
use async_std::task;
|
use async_std::task;
|
||||||
use async_std::channel;
|
use async_std::channel;
|
||||||
use async_std::channel::Sender;
|
use async_std::channel::Sender;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
use rust_util::XResult;
|
use rust_util::XResult;
|
||||||
|
|
||||||
|
// "example.com" -> ("@", "example.com")
|
||||||
|
// "www.example.com" -> ("www", "example.com")
|
||||||
pub fn parse_dns_record(record: &str) -> XResult<(String, String)> {
|
pub fn parse_dns_record(record: &str) -> XResult<(String, String)> {
|
||||||
let r = if record.ends_with(".") {
|
let r = if record.ends_with(".") {
|
||||||
record.chars().take(record.len() - 1).collect::<String>().to_ascii_lowercase()
|
record.chars().take(record.len() - 1).collect::<String>().to_ascii_lowercase()
|
||||||
@@ -18,7 +20,7 @@ pub fn parse_dns_record(record: &str) -> XResult<(String, String)> {
|
|||||||
// SHOULD read from: https://publicsuffix.org/
|
// SHOULD read from: https://publicsuffix.org/
|
||||||
let domain_parts_len = match last_part {
|
let domain_parts_len = match last_part {
|
||||||
"cn" => match last_part_2 {
|
"cn" => match last_part_2 {
|
||||||
"com" | "net" | "org" | "gov" => 3,
|
"com" | "net" | "org" | "gov" | "edu" => 3,
|
||||||
_ => 2,
|
_ => 2,
|
||||||
},
|
},
|
||||||
_ => 2,
|
_ => 2,
|
||||||
|
|||||||
Reference in New Issue
Block a user