Issue #12372 has been updated by Charles Nutter.


Thumbs up from JRuby. We'll merge this in when ruby-core agrees.

----------------------------------------
Bug #12372: Resolv::DNS does not fetch authority section resources when calling getresource(s)
https://bugs.ruby-lang.org/issues/12372#change-58752

* Author: Rafael Fernndez Lpez
* 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: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>