Project

General

Profile

Backport #11144

Backport 49095 into ruby 2.1

Added by mxposed (Nikolay Markov) about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
[ruby-core:69151]

Description

Right now resolv cannot resolve IPv6 address to hostname in ruby 2.1

markov@cauth01:~$ ruby -v
ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-linux-gnu]


markov@cauth01:~$ host 2a02:6b8::11
1.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.6.0.2.0.a.2.ip6.arpa domain name pointer yandex.ru.`


markov@cauth01:~$ cat test.rb 
#!/usr/bin/ruby

require 'resolv'
Resolv.getname('2a02:6b8::11')


markov@cauth01:~$ ./test.rb 
/usr/lib/ruby/2.1.0/resolv.rb`128:in `getname': no name for 2a02:6b8::11 (Resolv::ResolvError)
    from /usr/lib/ruby/2.1.0/resolv.rb:64:in `getname'
    from ./test.rb:5:in `<main>'

This is because Resolv::IPv6#to_name (https://bugs.ruby-lang.org/projects/ruby-21/repository/entry/lib/resolv.rb#L2506) creates Resolv::DNS::Name with an array of strings, however other instances are created with an array of Resolv::Label::Str.
This behaviour is fixed in commit https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/49095 where labels of Resolv::DNS::Name are normalized, but this commit is not backported to ruby 2.1

However backporting this https://bugs.ruby-lang.org/projects/ruby-21/repository/revisions/49775 introduced the issue

Associated revisions

Revision 0cddf1b4
Added by usa (Usaku NAKAMURA) about 4 years ago

merge revision(s) 49095: [Backport #11144]

    * lib/resolv.rb (Resolv::DNS::Label::Str#==): Check class equality.
      (Resolv::DNS::Name#initialize): Normalize labels as
      Resolv::DNS::Label::Str objects.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 50482
Added by usa (Usaku NAKAMURA) about 4 years ago

merge revision(s) 49095: [Backport #11144]

* lib/resolv.rb (Resolv::DNS::Label::Str#==): Check class equality.
  (Resolv::DNS::Name#initialize): Normalize labels as
  Resolv::DNS::Label::Str objects.

History

Updated by usa (Usaku NAKAMURA) about 4 years ago

Thank you very much for your in-depth explanation, Nikolay!

memo: ruby_2_2 is also needed to fix this.

#2

Updated by usa (Usaku NAKAMURA) about 4 years ago

  • Status changed from Open to Closed

Applied in changeset r50482.


merge revision(s) 49095: [Backport #11144]

* lib/resolv.rb (Resolv::DNS::Label::Str#==): Check class equality.
  (Resolv::DNS::Name#initialize): Normalize labels as
  Resolv::DNS::Label::Str objects.

Also available in: Atom PDF