mirror of
https://github.com/DNSCrypt/encrypted-dns-server.git
synced 2024-05-07 12:46:05 +02:00
Doh
This commit is contained in:
parent
c3ff5170b2
commit
3feb000d62
|
@ -74,12 +74,6 @@ version = "1.3.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.14.0"
|
||||
|
@ -119,7 +113,7 @@ version = "3.2.25"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bitflags",
|
||||
"clap_lex",
|
||||
"indexmap 1.9.3",
|
||||
"once_cell",
|
||||
|
@ -136,16 +130,6 @@ dependencies = [
|
|||
"os_str_bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clockpro-cache"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2009f347448d6c03472ac84e51a390c77ac8c1926c5a606ea18095b34d9c4e04"
|
||||
dependencies = [
|
||||
"bitflags 2.4.1",
|
||||
"slabigator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "coarsetime"
|
||||
version = "0.1.33"
|
||||
|
@ -234,7 +218,6 @@ dependencies = [
|
|||
"anyhow",
|
||||
"byteorder",
|
||||
"clap",
|
||||
"clockpro-cache",
|
||||
"coarsetime",
|
||||
"daemonize-simple",
|
||||
"derivative",
|
||||
|
@ -255,6 +238,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde-big-array",
|
||||
"serde_derive",
|
||||
"sieve-cache",
|
||||
"siphasher",
|
||||
"slabigator",
|
||||
"socket2",
|
||||
|
@ -720,7 +704,7 @@ version = "0.26.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"memoffset",
|
||||
|
@ -836,7 +820,7 @@ version = "0.12.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0941606b9934e2d98a3677759a971756eb821f75764d0e0d26946d08e74d9104"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bitflags",
|
||||
"byteorder",
|
||||
"hex",
|
||||
"lazy_static",
|
||||
|
@ -904,7 +888,7 @@ version = "0.4.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -954,7 +938,7 @@ version = "0.37.26"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84f3f8f960ed3b5a59055428714943298bf3fa2d4a1d53135084e0544829d995"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bitflags",
|
||||
"errno",
|
||||
"io-lifetimes",
|
||||
"libc",
|
||||
|
@ -1038,6 +1022,12 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sieve-cache"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa18fd0df90a1f0e477c5de20fc5084a9241f4352074d00316cd282990b7db57"
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "1.0.0"
|
||||
|
|
|
@ -19,7 +19,6 @@ clap = { version = "3.2.25", default-features = false, features = [
|
|||
"cargo",
|
||||
"wrap_help",
|
||||
] }
|
||||
clockpro-cache = "0.1.12"
|
||||
coarsetime = "0.1.33"
|
||||
daemonize-simple = "0.1.5"
|
||||
derivative = "2.2.0"
|
||||
|
@ -44,6 +43,7 @@ rustc-hash = "1.1.0"
|
|||
serde = "1.0.195"
|
||||
serde_derive = "1.0.195"
|
||||
serde-big-array = "0.5.1"
|
||||
sieve-cache = "0.1.3"
|
||||
siphasher = "1.0.0"
|
||||
slabigator = "0.9.1"
|
||||
tokio = { version = "1.35.1", features = [
|
||||
|
|
10
src/cache.rs
10
src/cache.rs
|
@ -1,8 +1,8 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use clockpro_cache::ClockProCache;
|
||||
use coarsetime::{Duration, Instant};
|
||||
use parking_lot::{Mutex, MutexGuard};
|
||||
use sieve_cache::SieveCache;
|
||||
|
||||
use crate::dns;
|
||||
|
||||
|
@ -55,7 +55,7 @@ impl CachedResponse {
|
|||
#[derivative(Debug)]
|
||||
pub struct Cache {
|
||||
#[derivative(Debug = "ignore")]
|
||||
cache: Arc<Mutex<ClockProCache<u128, CachedResponse>>>,
|
||||
cache: Arc<Mutex<SieveCache<u128, CachedResponse>>>,
|
||||
pub ttl_min: u32,
|
||||
pub ttl_max: u32,
|
||||
pub ttl_error: u32,
|
||||
|
@ -63,13 +63,13 @@ pub struct Cache {
|
|||
|
||||
impl Cache {
|
||||
pub fn new(
|
||||
clockpro_cache: ClockProCache<u128, CachedResponse>,
|
||||
sieve_cache: SieveCache<u128, CachedResponse>,
|
||||
ttl_min: u32,
|
||||
ttl_max: u32,
|
||||
ttl_error: u32,
|
||||
) -> Self {
|
||||
Cache {
|
||||
cache: Arc::new(Mutex::new(clockpro_cache)),
|
||||
cache: Arc::new(Mutex::new(sieve_cache)),
|
||||
ttl_min,
|
||||
ttl_max,
|
||||
ttl_error,
|
||||
|
@ -77,7 +77,7 @@ impl Cache {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn lock(&self) -> MutexGuard<'_, ClockProCache<u128, CachedResponse>> {
|
||||
pub fn lock(&self) -> MutexGuard<'_, SieveCache<u128, CachedResponse>> {
|
||||
self.cache.lock()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
|||
use std::time::SystemTime;
|
||||
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
use clockpro_cache::ClockProCache;
|
||||
use sieve_cache::SieveCache;
|
||||
use parking_lot::Mutex;
|
||||
use rand::prelude::*;
|
||||
use serde_big_array::BigArray;
|
||||
|
@ -108,7 +108,7 @@ pub struct DNSCryptEncryptionParams {
|
|||
resolver_kp: CryptKeyPair,
|
||||
#[serde(skip)]
|
||||
#[derivative(Debug = "ignore")]
|
||||
pub key_cache: Option<Arc<Mutex<ClockProCache<[u8; DNSCRYPT_QUERY_PK_SIZE], SharedKey>>>>,
|
||||
pub key_cache: Option<Arc<Mutex<SieveCache<[u8; DNSCRYPT_QUERY_PK_SIZE], SharedKey>>>>,
|
||||
}
|
||||
|
||||
impl DNSCryptEncryptionParams {
|
||||
|
@ -140,7 +140,7 @@ impl DNSCryptEncryptionParams {
|
|||
}
|
||||
if now >= ts_start {
|
||||
let dnscrypt_cert = DNSCryptCert::new(provider_kp, &resolver_kp, ts_start);
|
||||
let cache = ClockProCache::new(key_cache_capacity).unwrap();
|
||||
let cache = SieveCache::new(key_cache_capacity).unwrap();
|
||||
active_params.push(DNSCryptEncryptionParams {
|
||||
dnscrypt_cert,
|
||||
resolver_kp,
|
||||
|
@ -154,7 +154,7 @@ impl DNSCryptEncryptionParams {
|
|||
let ts_start = now - (now % DNSCRYPT_CERTS_RENEWAL);
|
||||
let resolver_kp = CryptKeyPair::from_seed(seed);
|
||||
let dnscrypt_cert = DNSCryptCert::new(provider_kp, &resolver_kp, ts_start);
|
||||
let cache = ClockProCache::new(key_cache_capacity).unwrap();
|
||||
let cache = SieveCache::new(key_cache_capacity).unwrap();
|
||||
active_params.push(DNSCryptEncryptionParams {
|
||||
dnscrypt_cert,
|
||||
resolver_kp,
|
||||
|
@ -165,7 +165,7 @@ impl DNSCryptEncryptionParams {
|
|||
}
|
||||
|
||||
pub fn add_key_cache(&mut self, cache_capacity: usize) {
|
||||
let cache = ClockProCache::new(cache_capacity).unwrap();
|
||||
let cache = SieveCache::new(cache_capacity).unwrap();
|
||||
self.key_cache = Some(Arc::new(Mutex::new(cache)));
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ use blacklist::*;
|
|||
use byteorder::{BigEndian, ByteOrder};
|
||||
use cache::*;
|
||||
use clap::Arg;
|
||||
use clockpro_cache::ClockProCache;
|
||||
use sieve_cache::SieveCache;
|
||||
use config::*;
|
||||
use crypto::*;
|
||||
use dns::*;
|
||||
|
@ -735,14 +735,14 @@ fn main() -> Result<(), Error> {
|
|||
let hasher = SipHasher13::new_with_keys(sh_k0, sh_k1);
|
||||
|
||||
let cache = Cache::new(
|
||||
ClockProCache::new(cache_capacity)
|
||||
SieveCache::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)
|
||||
SieveCache::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