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

[WIP][Greendns] Replace deprecated resolver.query by resolver.resolve #840

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions eventlet/support/greendns.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@
return end()

# Main query
step(self._resolver.query, qname, rdtype, rdclass, tcp, source, raise_on_no_answer=False)
step(self._resolver.resolve, qname, rdtype, rdclass, tcp, source,

Check warning on line 403 in eventlet/support/greendns.py

View check run for this annotation

Codecov / codecov/patch

eventlet/support/greendns.py#L403

Added line #L403 was not covered by tests
raise_on_no_answer=False, search=True)
Copy link
Member Author

@4383 4383 Dec 19, 2023

Choose a reason for hiding this comment

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

resolve and query doesn't have the same signature, and internally query call resolve with search=True, while this option is set to None by default.


# `resolv.conf` docs say unqualified names must resolve from search (or local) domain.
# However, common OS `getaddrinfo()` implementations append trailing dot (e.g. `db -> db.`)
Expand All @@ -409,8 +410,9 @@
# https://github.com/nameko/nameko/issues/392
# https://github.com/eventlet/eventlet/issues/363
if len(qname) == 1:
step(self._resolver.query, qname.concatenate(dns.name.root),
rdtype, rdclass, tcp, source, raise_on_no_answer=False)
step(self._resolver.resolve, qname.concatenate(dns.name.root),

Check warning on line 413 in eventlet/support/greendns.py

View check run for this annotation

Codecov / codecov/patch

eventlet/support/greendns.py#L413

Added line #L413 was not covered by tests
rdtype, rdclass, tcp, source, raise_on_no_answer=False,
search=True)

return end()

Expand Down Expand Up @@ -623,8 +625,9 @@

if is_ipv4_addr(host):
try:
rrset = resolver.query(
dns.reversename.from_address(host), dns.rdatatype.PTR)
rrset = resolver.resolve(

Check warning on line 628 in eventlet/support/greendns.py

View check run for this annotation

Codecov / codecov/patch

eventlet/support/greendns.py#L628

Added line #L628 was not covered by tests
dns.reversename.from_address(host), dns.rdatatype.PTR,
search=True)
if len(rrset) > 1:
raise socket.error('sockaddr resolved to multiple addresses')
host = rrset[0].target.to_text(omit_final_dot=True)
Expand All @@ -636,7 +639,7 @@
raise EAI_NONAME_ERROR
else:
try:
rrset = resolver.query(host)
rrset = resolver.resolve(host, search=True)

Check warning on line 642 in eventlet/support/greendns.py

View check run for this annotation

Codecov / codecov/patch

eventlet/support/greendns.py#L642

Added line #L642 was not covered by tests
if len(rrset) > 1:
raise socket.error('sockaddr resolved to multiple addresses')
if flags & socket.NI_NUMERICHOST:
Expand Down