Error if a loopback name server is used with a non-loopback local address, or vice versa #396
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #309
Changes
Description
In #389, we added this sort of "can't use a nameserver/local address that aren't both loopback or both not" validation to the config. But it is also possible to specify a name server in an individual input line:
echo "cloudflare.com,127.0.0.53" | ./zdns A
. In this case, our config validation will not error if the local address mismatches, since we're bypassing the config/CLI inputs to ZDNS.Solution is to validate in the resolver.Lookup itself. I think this should be done in addition to the config validation rather than replacing it, since catching the config error earlier leads to better UX.
Even prior to this change, it was not possible to specify both a loopback and non-loopback name server in the same scan. The mismatched query would timeout. This change just adds a descriptive error for the user to remediate the issue.
Example post-fix: