add DNS configuration for TCP fallback.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-04-16 05:41:55 -07:00 committed by June
parent b6cf0e6fcf
commit 8b003e6be2
3 changed files with 7 additions and 0 deletions

View file

@ -491,6 +491,9 @@ allow_profile_lookup_federation_requests = true
# Number of retries after a timeout. # Number of retries after a timeout.
#dns_attempts = 5 #dns_attempts = 5
# Fallback to TCP on DNS errors. Set this to false if unsupported by nameserver.
#dns_tcp_fallback = true
# Enable to query all nameservers until the domain is found. Referred to as "trust_negative_responses" in hickory_resolver. # Enable to query all nameservers until the domain is found. Referred to as "trust_negative_responses" in hickory_resolver.
# This can avoid useless DNS queries if the first nameserver responds with NXDOMAIN or an empty NOERROR response. # This can avoid useless DNS queries if the first nameserver responds with NXDOMAIN or an empty NOERROR response.
# #

View file

@ -98,6 +98,8 @@ pub struct Config {
pub dns_attempts: u16, pub dns_attempts: u16,
#[serde(default = "default_dns_timeout")] #[serde(default = "default_dns_timeout")]
pub dns_timeout: u64, pub dns_timeout: u64,
#[serde(default = "true_fn")]
pub dns_tcp_fallback: bool,
#[serde(default)] #[serde(default)]
pub query_all_nameservers: bool, pub query_all_nameservers: bool,
#[serde(default = "default_max_request_size")] #[serde(default = "default_max_request_size")]
@ -494,6 +496,7 @@ impl fmt::Display for Config {
("DNS minimum nxdomain ttl", &self.dns_min_ttl_nxdomain.to_string()), ("DNS minimum nxdomain ttl", &self.dns_min_ttl_nxdomain.to_string()),
("DNS attempts", &self.dns_attempts.to_string()), ("DNS attempts", &self.dns_attempts.to_string()),
("DNS timeout", &self.dns_timeout.to_string()), ("DNS timeout", &self.dns_timeout.to_string()),
("DNS fallback to TCP", &self.dns_tcp_fallback.to_string()),
("Query all nameservers", &self.query_all_nameservers.to_string()), ("Query all nameservers", &self.query_all_nameservers.to_string()),
("Maximum request size (bytes)", &self.max_request_size.to_string()), ("Maximum request size (bytes)", &self.max_request_size.to_string()),
("Maximum concurrent requests", &self.max_concurrent_requests.to_string()), ("Maximum concurrent requests", &self.max_concurrent_requests.to_string()),

View file

@ -64,6 +64,7 @@ impl Resolver {
opts.positive_max_ttl = Some(Duration::from_secs(60 * 60 * 24 * 7)); opts.positive_max_ttl = Some(Duration::from_secs(60 * 60 * 24 * 7));
opts.timeout = Duration::from_secs(config.dns_timeout); opts.timeout = Duration::from_secs(config.dns_timeout);
opts.attempts = config.dns_attempts as usize; opts.attempts = config.dns_attempts as usize;
opts.try_tcp_on_error = config.dns_tcp_fallback;
opts.num_concurrent_reqs = 1; opts.num_concurrent_reqs = 1;
opts.shuffle_dns_servers = true; opts.shuffle_dns_servers = true;
opts.rotate = true; opts.rotate = true;