add query_all_nameservers config option

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-26 21:32:10 -04:00 committed by June
parent cb12f285e9
commit 3d0f0cc1ce
4 changed files with 29 additions and 1 deletions

View file

@ -413,6 +413,12 @@ url_preview_check_root_domain = false
# Number of retries after a timeout. # Number of retries after a timeout.
#dns_attempts = 5 #dns_attempts = 5
# 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.
#
# The default is to query one nameserver and stop (false).
#query_all_nameservers = false
### Request Timeouts, Connection Timeouts, and Connection Pooling ### Request Timeouts, Connection Timeouts, and Connection Pooling

View file

@ -67,6 +67,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)]
pub query_all_nameservers: bool,
#[serde(default = "default_max_request_size")] #[serde(default = "default_max_request_size")]
pub max_request_size: u32, pub max_request_size: u32,
#[serde(default = "default_max_concurrent_requests")] #[serde(default = "default_max_concurrent_requests")]
@ -322,6 +324,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()),
("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()),
("Request connect timeout", &self.request_conn_timeout.to_string()), ("Request connect timeout", &self.request_conn_timeout.to_string()),
@ -511,6 +514,10 @@ impl fmt::Display for Config {
), ),
("URL preview maximum spider size", &self.url_preview_max_spider_size.to_string()), ("URL preview maximum spider size", &self.url_preview_max_spider_size.to_string()),
("URL preview check root domain", &self.url_preview_check_root_domain.to_string()), ("URL preview check root domain", &self.url_preview_check_root_domain.to_string()),
(
"Allow check for updates / announcements check",
&self.allow_check_for_updates.to_string(),
),
]; ];
let mut msg: String = "Active config values:\n\n".to_owned(); let mut msg: String = "Active config values:\n\n".to_owned();

View file

@ -235,6 +235,8 @@ impl Service<'_> {
pub fn dns_resolver(&self) -> &TokioAsyncResolver { &self.resolver.resolver } pub fn dns_resolver(&self) -> &TokioAsyncResolver { &self.resolver.resolver }
pub fn query_all_nameservers(&self) -> bool { self.config.query_all_nameservers }
pub fn actual_destinations(&self) -> &Arc<RwLock<resolver::WellKnownMap>> { &self.resolver.destinations } pub fn actual_destinations(&self) -> &Arc<RwLock<resolver::WellKnownMap>> { &self.resolver.destinations }
pub fn jwt_decoding_key(&self) -> Option<&jsonwebtoken::DecodingKey> { self.jwt_decoding_key.as_ref() } pub fn jwt_decoding_key(&self) -> Option<&jsonwebtoken::DecodingKey> { self.jwt_decoding_key.as_ref() }

View file

@ -40,9 +40,22 @@ impl Resolver {
.unwrap(); .unwrap();
let mut conf = hickory_resolver::config::ResolverConfig::new(); let mut conf = hickory_resolver::config::ResolverConfig::new();
if let Some(domain) = sys_conf.domain() {
conf.set_domain(domain.clone());
}
for sys_conf in sys_conf.search() {
conf.add_search(sys_conf.clone());
}
for sys_conf in sys_conf.name_servers() { for sys_conf in sys_conf.name_servers() {
let mut ns = sys_conf.clone(); let mut ns = sys_conf.clone();
ns.trust_negative_responses = true;
if config.query_all_nameservers {
ns.trust_negative_responses = true;
}
conf.add_name_server(ns); conf.add_name_server(ns);
} }