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

Async::DNS::Resolver will return Resolv::DNS::Resource::IN::CNAME when Resolv::DNS::Resource::IN::SRV is requested #28

Open
postmodern opened this issue Apr 17, 2023 · 4 comments

Comments

@postmodern
Copy link
Contributor

postmodern commented Apr 17, 2023

I noticed that Async::DNS::Resolver will return CNAME records when querying SRV records for a domain that maps unknown sub-domains to a catch-all alias (ex: github.com). Where as Resolv::DNS will return an empty Array since the response records do not match the requested resource type.

This could be fixed by simply filtering the response records by class.

Steps To Reproduce

require 'async/dns'
require 'resolv'

async_resolver = Async::DNS::Resolver.new([[:udp, '8.8.8.8', 53]])

Async do
  response = async_resolver.query('_xmpp-server._tcp.github.com', Resolv::DNS::Resource::IN::SRV)
  records  = response.answer.map { |answer| answer[2] }

  p records
end

resolve = Resolv::DNS.new(nameserver: %w[8.8.8.8])
records = resolve.getresources('_xmpp-server._tcp.github.com', Resolv::DNS::Resource::IN::SRV)
p records

Expected Behavior

[]
[]

Actual Behavior

[#<Resolv::DNS::Resource::IN::CNAME:0x00007f4027885400 @name=#<Resolv::DNS::Name: github.github.io.>, @ttl=3499>]
[]

Additional Information

  • ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]
  • async-dns (1.3.0)
@postmodern postmodern changed the title Async::DNS::Resolve will return Resolv::DNS::Resource::IN::CNAME when Resolv::DNS::Resource::IN::SRV is requested Async::DNS::Resolver will return Resolv::DNS::Resource::IN::CNAME when Resolv::DNS::Resource::IN::SRV is requested Apr 17, 2023
@ioquatix
Copy link
Member

If making such a query gives such a response, I'm not sure we should filter it, at least not at the resolver level. Maybe a higher level interface like "get addresses" or such should do that though.

@postmodern
Copy link
Contributor Author

If the user is explicitly querying a specific type of DNS record, and they get back another kind of record, this will likely cause a bug (no method target for ...) or require the developer to add their own filtering.

@postmodern
Copy link
Contributor Author

Also running into this when querying MX records for potato.com, which is a CNAME to cs.62.net. I noticed that Resolv::DNS#getresources will actually filter the records by the given Resolv::DNS::Resource::IN:: class.

@ioquatix
Copy link
Member

I'll take a look and see what we can do.

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

No branches or pull requests

2 participants