add ip_lookup_strategy config option for hickory resolver
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
3f8407dd64
commit
668a7645e9
|
@ -514,6 +514,21 @@ allow_profile_lookup_federation_requests = true
|
|||
# The default is to query one nameserver and stop (false).
|
||||
#query_all_nameservers = true
|
||||
|
||||
# DNS A/AAAA record lookup strategy
|
||||
#
|
||||
# Takes a number of one of the following options:
|
||||
# 1 - Ipv4Only (Only query for A records, no AAAA/IPv6)
|
||||
# 2 - Ipv6Only (Only query for AAAA records, no A/IPv4)
|
||||
# 3 - Ipv4AndIpv6 (Query for A and AAAA records in parallel, uses whatever returns a successful response first)
|
||||
# 4 - Ipv6thenIpv4 (Query for AAAA record, if that fails then query the A record)
|
||||
# 5 - Ipv4thenIpv6 (Query for A record, if that fails then query the AAAA record)
|
||||
#
|
||||
# If you don't have IPv6 networking, then for better performance it may be suitable to set this to Ipv4Only (1) as
|
||||
# you will never ever use the AAAA record contents even if the AAAA record is successful instead of the A record.
|
||||
#
|
||||
# Defaults to 5 - Ipv4ThenIpv6 as this is the most compatible and IPv4 networking is currently the most prevalent.
|
||||
#ip_lookup_strategy = 5
|
||||
|
||||
|
||||
### Request Timeouts, Connection Timeouts, and Connection Pooling
|
||||
|
||||
|
|
|
@ -103,6 +103,8 @@ pub(crate) struct Config {
|
|||
pub(crate) dns_tcp_fallback: bool,
|
||||
#[serde(default = "true_fn")]
|
||||
pub(crate) query_all_nameservers: bool,
|
||||
#[serde(default = "default_ip_lookup_strategy")]
|
||||
pub(crate) ip_lookup_strategy: u8,
|
||||
|
||||
#[serde(default = "default_max_request_size")]
|
||||
pub(crate) max_request_size: u32,
|
||||
|
@ -902,6 +904,8 @@ fn default_dns_attempts() -> u16 { 10 }
|
|||
|
||||
fn default_dns_timeout() -> u64 { 10 }
|
||||
|
||||
fn default_ip_lookup_strategy() -> u8 { 5 }
|
||||
|
||||
fn default_max_request_size() -> u32 {
|
||||
20 * 1024 * 1024 // Default to 20 MB
|
||||
}
|
||||
|
|
|
@ -67,6 +67,13 @@ impl Resolver {
|
|||
opts.num_concurrent_reqs = 1;
|
||||
opts.shuffle_dns_servers = true;
|
||||
opts.rotate = true;
|
||||
opts.ip_strategy = match config.ip_lookup_strategy {
|
||||
1 => hickory_resolver::config::LookupIpStrategy::Ipv4Only,
|
||||
2 => hickory_resolver::config::LookupIpStrategy::Ipv6Only,
|
||||
3 => hickory_resolver::config::LookupIpStrategy::Ipv4AndIpv6,
|
||||
4 => hickory_resolver::config::LookupIpStrategy::Ipv6thenIpv4,
|
||||
_ => hickory_resolver::config::LookupIpStrategy::Ipv4thenIpv6,
|
||||
};
|
||||
|
||||
let resolver = Arc::new(TokioAsyncResolver::tokio(conf, opts));
|
||||
let overrides = Arc::new(StdRwLock::new(TlsNameMap::new()));
|
||||
|
|
Loading…
Reference in New Issue