Resolv.getname with IPv6 noop
Currently reverse resolving IPv6 addresses using stdlib Resolv does not work.
- Require 'resolv'
- Use #getname or #getnames with a valid, reverse resolvable IPv6 address
resolv error with #getname, empty result using #getnames
Resolved to hostname as with IPv4
dig @18.104.22.168 +short -x 2a00:1450:4001:803::1018 fra07s30-in-x18.1e100.net.
 pry(main)> require 'resolv' => false  pry(main)> resolver = Resolv::DNS.new(:nameserver => '22.214.171.124') #[...]  pry(main)> resolver.getname('2a00:1450:4001:803::1018') Resolv::ResolvError: no name for 2a00:1450:4001:803::1018 from ~/.rvm/rubies/ruby-2.0.0-p643/lib/ruby/2.0.0/resolv.rb:128:in `getname'  pry(main)> resolver.getnames('2a00:1450:4001:803::1018') => 
Updated by wb (Dmitri Dolguikh) over 5 years ago
I'm seeing this issue on 2.0.0, 2.2.1, 2.2.2, but not 1.9.3 and 2.2.3 (I suspect all versions between 2.0.0 and 2.2.3 are broken).
This is due to how Resolv::IPv6#to_name and Resolv::Name.initialize work. In 2.2.3 Resolv::Name constructor was changed to convert labels to Resolv::Label::Str. Before that any comparison beween instances of Resolv::Name constructed from a string via Resolv::Name.create and Resolv::Name.new would fail. 1.9.3 is a bit different, as it's implementation of Resolv::Name.== converts labels to a string for the comparison.
Patch for ruby_2_0_0 branch attached.