New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make AsyncResolver take hosts file into account #2149
base: main
Are you sure you want to change the base?
Conversation
Pushed a new commit that resolves the FQDN issue, although I am not sure whether it is the correct fix or not. |
It seems quite surprising that the |
I generally agree @djc. For some background here, the Hosts file lookup is only valuable in the context of IP lookups, which is why there's different code paths here. I agree with unifying them. There's a challenge here that as I remember was around the generic interface that I need to look at this in more detail when I have time to offer some better guidance here. |
The hosts file part seems kind of straightforward at least, since you could just handle it only for |
The main problem with merging |
Maybe for now it would be good enough to just move the hosts file lookup from |
Duplicating hosts lookup in both |
|
||
// Ignore FQDN when we forward DNS queries. Without this we can't look | ||
// up addresses from system hosts file. | ||
let mut name: Name = name.clone().into(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a non-trivial change -- why do you think this is the right thing to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The query sent to upstream DNS is the same no matter FQDN is enabled or not. It seems that FQDN only affects hosts lookup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want the Forwarder to use the local resolve config at all? Do other DNS servers do that on forwarded requests? I don't think so. I think if we want a Hosts file to be used, we should create a separate Authority type for that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think dnsmasq
does that, not too sure though... But maybe we can disable use_hosts_file
by default in ForwardConfig?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good to me.
Overall, I think I'm ok with this change, on the Forwarder, I think we actually don't want the resolve config file to be referenced, if I enabled that in the past, it probably was a poor decision. |
To be clear, I think this is ready to land if we could just clean up the setup for the Forwarded Authority. |
I think your branch looks okay, but I think it would be helpful to use an explicit Would propose something like: enum ResolveHosts {
Always,
Never,
Default, // maybe not the best name? `Depends` or `Contextual` or ...
} |
I opted to name the third variant |
Without this we can't look up addresses from system hosts file.
The Auto option is meant to allow downstream users to intercept the config and replace it with what they deem to be suitable.
Closes #2148.
I'm creating the PR for feedback.
This does not actually work. Given aThis is fixed by 9564566./etc/hosts
file containing201.11.11.11 example.com
, looking up the A record forexample.com.
usingAsyncResolver
will still return93.184.216.34
, so FQDN seems to tripHosts::lookup_static_host()
up.