From a5acc158002afb0c5a25e78e0d070738f20a2b38 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 31 Jan 2021 12:24:02 +0100 Subject: [PATCH] Try CART cache --- Cargo.toml | 2 +- src/cache.rs | 8 ++++---- src/dnscrypt_certs.rs | 8 ++++---- src/main.rs | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 92cb364..b34d641 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ readme = "README.md" anyhow = "1.0.38" byteorder = "1.4.2" clap = { version = "2.33.3", default-features = false, features = ["wrap_help"] } -clockpro-cache = "0.1.9" +cart-cache = "0.1.5" coarsetime = "0.1.18" daemonize-simple = "0.1.4" derivative = "2.2.0" diff --git a/src/cache.rs b/src/cache.rs index d9da4b7..9bed6f6 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -1,6 +1,6 @@ use crate::dns; -use clockpro_cache::ClockProCache; +use cart_cache::CartCache; use coarsetime::{Duration, Instant}; use parking_lot::{Mutex, MutexGuard}; use std::sync::Arc; @@ -54,7 +54,7 @@ impl CachedResponse { #[derivative(Debug)] pub struct Cache { #[derivative(Debug = "ignore")] - cache: Arc>>, + cache: Arc>>, pub ttl_min: u32, pub ttl_max: u32, pub ttl_error: u32, @@ -62,7 +62,7 @@ pub struct Cache { impl Cache { pub fn new( - clockpro_cache: ClockProCache, + clockpro_cache: CartCache, ttl_min: u32, ttl_max: u32, ttl_error: u32, @@ -76,7 +76,7 @@ impl Cache { } #[inline] - pub fn lock(&self) -> MutexGuard<'_, ClockProCache> { + pub fn lock(&self) -> MutexGuard<'_, CartCache> { self.cache.lock() } } diff --git a/src/dnscrypt_certs.rs b/src/dnscrypt_certs.rs index bd2320a..834a71c 100644 --- a/src/dnscrypt_certs.rs +++ b/src/dnscrypt_certs.rs @@ -5,7 +5,7 @@ use crate::dnscrypt::*; use crate::globals::*; use byteorder::{BigEndian, ByteOrder}; -use clockpro_cache::ClockProCache; +use cart_cache::CartCache; use parking_lot::Mutex; use std::mem; use std::slice; @@ -104,7 +104,7 @@ pub struct DNSCryptEncryptionParams { resolver_kp: CryptKeyPair, #[serde(skip)] #[derivative(Debug = "ignore")] - pub cache: Option>>>, + pub cache: Option>>>, } impl DNSCryptEncryptionParams { @@ -116,7 +116,7 @@ impl DNSCryptEncryptionParams { == &ANONYMIZED_DNSCRYPT_QUERY_MAGIC[..DNSCRYPT_QUERY_MAGIC_SIZE] } {} let dnscrypt_cert = DNSCryptCert::new(&provider_kp, &resolver_kp); - let cache = ClockProCache::new(cache_capacity).unwrap(); + let cache = CartCache::new(cache_capacity).unwrap(); DNSCryptEncryptionParams { dnscrypt_cert, resolver_kp, @@ -125,7 +125,7 @@ impl DNSCryptEncryptionParams { } pub fn add_key_cache(&mut self, cache_capacity: usize) { - let cache = ClockProCache::new(cache_capacity).unwrap(); + let cache = CartCache::new(cache_capacity).unwrap(); self.cache = Some(Arc::new(Mutex::new(cache))); } diff --git a/src/main.rs b/src/main.rs index c1d7ea0..c423af8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,8 +50,8 @@ use globals::*; use varz::*; use byteorder::{BigEndian, ByteOrder}; +use cart_cache::CartCache; use clap::Arg; -use clockpro_cache::ClockProCache; use dnsstamps::{InformalProperty, WithInformalProperty}; use futures::join; use futures::prelude::*; @@ -643,14 +643,14 @@ fn main() -> Result<(), Error> { let hasher = SipHasher13::new_with_keys(sh_k0, sh_k1); let cache = Cache::new( - ClockProCache::new(cache_capacity) + CartCache::new(cache_capacity) .map_err(|e| anyhow!("Unable to create the DNS cache: [{}]", e))?, config.cache_ttl_min, config.cache_ttl_max, config.cache_ttl_error, ); let cert_cache = Cache::new( - ClockProCache::new(RELAYED_CERT_CACHE_SIZE) + CartCache::new(RELAYED_CERT_CACHE_SIZE) .map_err(|e| anyhow!("Unable to create the relay cert cache: [{}]", e))?, RELAYED_CERT_CACHE_TTL, RELAYED_CERT_CACHE_TTL,