Actions
Bug #12372
closedResolv::DNS does not fetch authority section resources when calling getresource(s)
Description
In some cases, for example, when trying to retrieve the nameservers of a domain, you need to ask authoritative servers:
> dig ns org
(...)
;; ANSWER SECTION:
org. 13729 IN NS a0.org.afilias-nst.info.
org. 13729 IN NS a2.org.afilias-nst.info.
org. 13729 IN NS b0.org.afilias-nst.org.
org. 13729 IN NS b2.org.afilias-nst.org.
org. 13729 IN NS c0.org.afilias-nst.info.
org. 13729 IN NS d0.org.afilias-nst.org.
(pick one)
> dig ns ruby-lang.org @a0.org.afilias-nst.info
(...)
;; AUTHORITY SECTION:
ruby-lang.org. 86400 IN NS pichu.netlab.jp.
ruby-lang.org. 86400 IN NS support.netlab.jp.
The last reply (that returns the nameserver of the ruby-lang.org domain) comes in the authority section of the DNS message reply. Doing this with Resolv::DNS is very tricky right now:
require 'resolv'
dns = Resolv::DNS.new(:nameserver => ['199.19.56.1'])
puts dns.getresources('ruby-lang.org', Resolv::DNS::Resource::IN::NS).map(&:name)
Resolv::DNS is internally calling on extract_resources to each_answer, which only fetches the answer part of the DNS message reply. I created a pull request some time ago (https://github.com/ruby/ruby/pull/797), so it would internally call each_resource that internally collects each_answer, each_authority and each_additional.
Updated by ereslibre (Rafael Fernández López) over 8 years ago
- ruby -v set to All versions (1.1.8 - trunk)
Updated by headius (Charles Nutter) over 8 years ago
Thumbs up from JRuby. We'll merge this in when ruby-core agrees.
Updated by headius (Charles Nutter) over 8 years ago
Ping again.
Actions
Like0
Like0Like0Like0Like0