From: ereslibre@... Date: 2016-05-12T15:40:02+00:00 Subject: [ruby-core:75473] [Ruby trunk Bug#12372] Resolv::DNS does not fetch authority section resources when calling getresource(s) Issue #12372 has been updated by Rafael Fern��ndez L��pez. ruby -v set to All versions (1.1.8 - trunk) ---------------------------------------- Bug #12372: Resolv::DNS does not fetch authority section resources when calling getresource(s) https://bugs.ruby-lang.org/issues/12372#change-58594 * Author: Rafael Fern��ndez L��pez * Status: Open * Priority: Normal * Assignee: * ruby -v: All versions (1.1.8 - trunk) * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- 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. -- https://bugs.ruby-lang.org/ Unsubscribe: