Skip to content
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

Fix domain names resolution #1488

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open

Fix domain names resolution #1488

wants to merge 4 commits into from

Conversation

taroved
Copy link
Contributor

@taroved taroved commented Dec 4, 2020

I'm going to implement dns names resolution. The current fix replace dns ANY request with A and AAAA requests.

Current ANY request doesn't provide IP addresses for most domain names

Copy link
Member

@exarkun exarkun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This looks like a good start. I've left some comments inline. Additionally, it would be good to have a test for the A and AAAA codepaths here.

I see that getHostByName does have test coverage now but whatever existing tests there are were passing before so they're not proving the use of A/AAAA.

I wonder if twisted.names.test.test_client.FakeResolver could just go away, removing the now-uncommon behavior of guaranteeing an A response to an ANY query.

Thanks again for your efforts so far.

@@ -0,0 +1 @@
Replace dns client ANY request with A and AAAA requests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't follow the style-guide for newsfragments: https://twistedmatrix.com/trac/wiki/ReviewProcess#Newsfiles

Perhaps:

twisted.names.common.ResolverBase.getHostByName now uses A and AAAA queries instead of ANY queries.

Copy link
Contributor

@wiml wiml Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Replace dns client ANY request with A and AAAA requests
twisted.names.common.ResolverBase.getHostByName now makes specific queries for A and AAAA records instead of an ANY query.

return d

def _cbRecords(self, records, name, effort):
def _cbRecordsA(self, records, name, effort, timeout):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A docstring for this method would be nice.

return d
return result

def _cbRecordsAAAA(self, records, name, effort):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A docstring for this method would be nice.

Copy link

@ShadowJonathan ShadowJonathan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small objection, but otherwise, looks fine

(ans, auth, add) = records
result = extractRecord(self, dns.Name(name), ans + auth + add, effort)
if not result:
# if A lookup doesn't provide IP then lookup AAAA

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be wise to lookup AAAA records regardless of A results, it makes IPv6 stand on even field as IPv4, as perceived DNS requests (A vs AAAA) would even out, and it could help further adoption of IPv6

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it might make a good follow-up.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by that? Make another PR which applies this suggestion?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File a ticket that describes the problem or the improved desired behavior and then make a PR that resolves it, yes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @ShadowJonathan that it should make queries for both A and AAAA by default, probably in parallel. It might also be worth making this behavior configurable for hosts that are ipv4-only, That seems like a good thing to put into a separate ticket+PR unless @taroved feels the need to do it in this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wiml I don't know how to do it in parallel. I think that it good thing to put into a separate ticket+PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants