1
1
Fork 0
mirror of https://github.com/DNSCrypt/encrypted-dns-server.git synced 2024-05-18 20:06:05 +02:00

Prepare a new configuration section for Anonymized DNS

This commit is contained in:
Frank Denis 2019-10-13 22:47:57 +02:00
parent 5437f80bfc
commit 72dfb0628c
4 changed files with 25 additions and 1 deletions

View File

@ -180,3 +180,13 @@ key_cache_capacity = 10000
# type = "prometheus"
# listen_addr = "0.0.0.0:9100"
# path = "/metrics"
################################
# Anonymized DNS #
################################
[anonymized_dns]
enabled = false

View File

@ -9,6 +9,11 @@ use std::net::{IpAddr, SocketAddr};
use std::path::{Path, PathBuf};
use tokio::prelude::*;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct AnonymizedDNSConfig {
pub enabled: bool,
}
#[cfg(feature = "metrics")]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MetricsConfig {
@ -67,6 +72,7 @@ pub struct Config {
pub log_file: Option<PathBuf>,
#[cfg(feature = "metrics")]
pub metrics: Option<MetricsConfig>,
pub anonymized_dns: Option<AnonymizedDNSConfig>,
}
impl Config {

View File

@ -43,4 +43,5 @@ pub struct Globals {
#[cfg(feature = "metrics")]
#[derivative(Debug = "ignore")]
pub varz: Varz,
pub anonymized_dns_enabled: bool,
}

View File

@ -172,7 +172,9 @@ async fn handle_client_query(
"Short packet"
);
debug_assert!(DNSCRYPT_QUERY_MIN_OVERHEAD > ANONYMIZED_DNSCRYPT_QUERY_MAGIC.len());
if encrypted_packet[..ANONYMIZED_DNSCRYPT_QUERY_MAGIC.len()] == ANONYMIZED_DNSCRYPT_QUERY_MAGIC
if globals.anonymized_dns_enabled
&& encrypted_packet[..ANONYMIZED_DNSCRYPT_QUERY_MAGIC.len()]
== ANONYMIZED_DNSCRYPT_QUERY_MAGIC
{
return handle_anonymized_dns(
globals,
@ -582,6 +584,10 @@ fn main() -> Result<(), Error> {
.map_err(|e| format_err!("Unable to load the blacklist [{:?}]: [{}]", path, e))?,
),
};
let anonymized_dns_enabled = match config.anonymized_dns {
None => false,
Some(anonymized_dns) => anonymized_dns.enabled,
};
let globals = Arc::new(Globals {
runtime: runtime.clone(),
state_file: state_file.to_path_buf(),
@ -612,6 +618,7 @@ fn main() -> Result<(), Error> {
blacklist,
#[cfg(feature = "metrics")]
varz: Varz::default(),
anonymized_dns_enabled,
});
let updater = DNSCryptEncryptionParamsUpdater::new(globals.clone());
if !state_is_new {