mirror of
https://github.com/jedisct1/encrypted-dns-server
synced 2024-11-12 13:10:44 +00:00
Try CART cache
This commit is contained in:
parent
897d854362
commit
a5acc15800
@ -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"
|
||||
|
@ -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<Mutex<ClockProCache<u128, CachedResponse>>>,
|
||||
cache: Arc<Mutex<CartCache<u128, CachedResponse>>>,
|
||||
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<u128, CachedResponse>,
|
||||
clockpro_cache: CartCache<u128, CachedResponse>,
|
||||
ttl_min: u32,
|
||||
ttl_max: u32,
|
||||
ttl_error: u32,
|
||||
@ -76,7 +76,7 @@ impl Cache {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn lock(&self) -> MutexGuard<'_, ClockProCache<u128, CachedResponse>> {
|
||||
pub fn lock(&self) -> MutexGuard<'_, CartCache<u128, CachedResponse>> {
|
||||
self.cache.lock()
|
||||
}
|
||||
}
|
||||
|
@ -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<Arc<Mutex<ClockProCache<[u8; DNSCRYPT_QUERY_PK_SIZE], SharedKey>>>>,
|
||||
pub cache: Option<Arc<Mutex<CartCache<[u8; DNSCRYPT_QUERY_PK_SIZE], SharedKey>>>>,
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user