feat: v0.2.0-rc
This commit is contained in:
19
src/app.rs
19
src/app.rs
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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,
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user