libvmod-dynamic icon indicating copy to clipboard operation
libvmod-dynamic copied to clipboard

Add resolver fallback to the null resolver (getaddrinfo)

Open delthas opened this issue 1 year ago • 2 comments

This enables a best-effort, two-step resolution when a resolver is configured:

  • if the DNS resolver returns any domain, that record is used with its corresponding TTL
  • otherwise, the module tries resolving the name with the default, NULL resolver, which is just a wrapper over getaddrinfo
    • if the resolution succeeds, this was likely a domain in /etc/hosts or an IP literal, which was not known by the DNS server. The associated record has no TTL value and uses the default director TTL.
    • if the resolution fails, this was likely a bad domain. No records are stored and a new request is made after the default director TTL, as was done previously.

The patch is somewhat dumb, it just wraps the resolve logic in a loop that can iterate twice. The goal was to minimize the size of git diff -w.

This causes the module to log Lookup & Results & Error twice in case we do the fallback attempt, which could be a nice side-effect (we can investigate a DNS error in varnishlog but see that it still succeeded). I don't have a strong opinion about this one.

Feel free to amend and merge if you'd like. Otherwise I can make changes. :smile:

delthas avatar Jul 25 '23 12:07 delthas