hickory-dns / hickory-dns

A Rust based DNS client, server, and resolver
Other
4.07k stars 465 forks source link

ResolverOpts: Disable caching is ignored in 0.18.0-alpha.1 #922

Open ivanceras opened 4 years ago

ivanceras commented 4 years ago

Describe the bug The api just keeps returning the same set of txt_records, excluding the new ones I have just added, even though I can see that it has been propagated using tools like: https://mxtoolbox.com/

To Reproduce I have this config to lookup for the txt_record of a domain.

    let mut resolver_opts = ResolverOpts::default();
    resolver_opts.cache_size = 0;
    resolver_opts.use_hosts_file = false;
    resolver_opts.validate = true;

I also tried using the default ResolverOpts only, but still has the same results.

If it's relevant I use my own supplied IP addresses which is the same provided by the IP. I have a plan to add different IP's in the future.

const CLOUDFLARE: &str = "1.1.1.1";
const GOOGLE: &str = "8.8.8.8";
const QUAD9: &str = "9.9.9.9";
const GOOGLE_ALT: &str = "8.8.4.4";

lazy_static::lazy_static! {
    pub static ref IP_STRS: [&'static str; 4] = [GOOGLE, CLOUDFLARE, QUAD9, GOOGLE_ALT];
    pub static ref DNS_IP: Vec<IpAddr> = IP_STRS.into_iter().map(|ip| IpAddr::V4(ip.parse().unwrap())).collect();
}

    let mut resolver_opts = ResolverOpts::default();
    resolver_opts.cache_size = 0;
    resolver_opts.use_hosts_file = false;
    resolver_opts.validate = true;
    let (resolver, bg_future) = AsyncResolver::new(
        ResolverConfig::from_parts(None, vec![], NameServerConfigGroup::from_ips_clear(&DNS_IP, 53)),
        resolver_opts,
    );
    tokio::spawn(bg_future);
    let result = resolver.txt_lookup(domain).await?;
    Ok(result.into_iter().collect())

Expected behavior If I keep calling the api to return the TXT_RECORD, before and after my newly added TXT_RECORD, it should somehow pull from the DNS servers instead of keep returning the same set cached txt_records.

System:

Version: Crate: resolver Version: 0.18.0-alpha.1

Additional context I tried out the new version because of the new async/await syntax, but it has some caching issues.

bluejekyll commented 4 years ago

What is the TTL on the TXT records? We have a lot of tests around the caching, but if the TTL is high, we will cache it for that period of time.

ivanceras commented 4 years ago

Oh, I missed out that detail. I always put 1 minute on the TTL everytime I put a TXT record.

bluejekyll commented 4 years ago

Ok, thanks for the report. I'll have to review the tests to try and see if there is something that's amiss.