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
3 changed files with 26 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue