-
Notifications
You must be signed in to change notification settings - Fork 126
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
Allow users to specify name-servers in input regardless of nameservers/local addresses supplied with flags #437
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ing tests on macbook
phillip-stephens
changed the title
DRAFT - Allow users to specify name-servers in input regardless of nameservers/local addresses supplied with flags
Allow users to specify name-servers in input regardless of nameservers/local addresses supplied with flags
Sep 5, 2024
zakird
approved these changes
Sep 5, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #436
You can't connect to a non-loopback nameserver with a loopback local address, and vice-versa. Prior to this change, lots of validation/unit tests were added to ensure that if loopback/non-loopback addresses (local addresses, name servers) were mixed in the
ResolverConfig
, an error would be thrown. The thinking was that after validation, we could be sure we could reach any nameserver we tried with thelocalAddress
stored.However, this approach doesn't work for the reasonable example:
echo "google.com,1.1.1.1" | ./zdns A
when/etc/resolv.conf
contains only loopback addressesSince in the absence of user-supplied
--name-servers
, we use/etc/resolv.conf
to fill them in, the above would fail since theResolver
would have a loopback local address, but then we'd attempt to query an internet-routable IP.The solution I settled on was to stop checking for this loopback mismatch and just get local addresses/sockets on-demand. Users are free to mix and match as they like. For example, the following works:
And you can even mix and match loopback and non-loopback too
Notice we're able to use both a loopback and non-loopback nameservers just fine. This is accomplished by creating
connectionInfo
objects on-demand rather than atResolver
initiation. If a user never needs a loopback UDP socket, one is not created. But once it's created, it will be saved so we don't have to re-open the socket.Reprecussions
One outcome/downside of this approach is we no longer validate if a name-server is reachable at
Resolver
startup` from the current local addresses. We just try it and see if it works. So the following don't error until the lookup is attempted.In the below example, this host lacks IPv6 connectivity. We don't error at
Resolver
init, but in the query itself.Testing
I've run the test suite on GH, on a host without IPv6 connectivity and with, and with loopback NS's in
/etc/resolv.conf
and without.Spot-checked a couple modules while varying
--4
/--6
,--iterative
,/etc/resolv.conf
with + without loopback.Performance
One area of concern is around the creation of sockets on-demand. If it's working as I intended it shouldn't matter, each resolver creates a socket of whatever type just once. Testing shows no noticeable regression compared to
main
.When running
make benchmark
main
- 36.15 s.branch
- 31.93 s.Note to Reviewers
Check out
getConnectionInfo
here, it has the "on-demand" socket creation