feat: v0.2.0-rc

This commit is contained in:
2024-03-30 16:42:22 +08:00
parent 5bfa8c9f9f
commit 6f7e7276b2
4 changed files with 11 additions and 16 deletions

View File

@@ -53,19 +53,14 @@ impl ProxyApp {
Ok(ips) => {
let records = ips.as_lookup().records();
for record in records {
if let Some(rdata) = record.data() {
match rdata {
RData::A(a) => {
let ipv4_address = a.0.to_string();
{
self.dns_resolver_cache_map.write().await
.insert(hostname.to_string(), ipv4_address.clone());
}
log::info!("DNS found {} --> {}", hostname, ipv4_address);
return Some(ipv4_address);
}
_ => {}
if let Some(RData::A(a)) = record.data() {
let ipv4_address = a.0.to_string();
{
self.dns_resolver_cache_map.write().await
.insert(hostname.to_string(), ipv4_address.clone());
}
log::info!("DNS found {} --> {}", hostname, ipv4_address);
return Some(ipv4_address);
}
}
}

View File

@@ -27,7 +27,7 @@ pub fn load_certificate(cert_fn: &str, key_fn: &str) -> Result<(Certificate, Str
pub fn issue_certificate(intermediate_certificate: &Certificate, domain: &str) -> Result<Cert, String> {
let cert = new_end_entity(domain)?;
log::info!("New certificate for: {} -> {}", domain, hex::encode(&cert.get_key_identifier()));
log::info!("New certificate for: {} -> {}", domain, hex::encode(cert.get_key_identifier()));
let cert_pem = cert.serialize_pem_with_signer(intermediate_certificate).map_err(|e| format!("Sign cert failed: {}", e))?;
let key_pem = cert.serialize_private_key_pem();
Ok(Cert {
@@ -79,7 +79,7 @@ fn new_end_entity(domain: &str) -> Result<Certificate, String> {
params.extended_key_usages.push(ExtendedKeyUsagePurpose::ClientAuth);
params.not_before = start;
params.not_after = end;
Ok(Certificate::from_params(params).map_err(|e| format!("New cert failed: {}", e))?)
Certificate::from_params(params).map_err(|e| format!("New cert failed: {}", e))
}
fn validity_period() -> Result<(OffsetDateTime, OffsetDateTime), String> {

View File

@@ -65,7 +65,7 @@ fn build_services(server: &Server, proxy_config: &ProxyConfig) -> Vec<Box<dyn Se
&server.configuration,
&listen_address,
lookup_dns,
&proxy_tls,
proxy_tls,
host_configs,
)));
}

View File

@@ -38,7 +38,7 @@ impl Callback {
return Ok(cert.clone());
}
}
let cert = cert::issue_certificate(&self.intermediate_certificate, &hostname)?;
let cert = cert::issue_certificate(&self.intermediate_certificate, hostname)?;
{
self.certificate_cache_map.write().await.insert(hostname.to_string(), cert.clone());
}