Fixed unexpected behavior of `Resolv::MDNS#each_address` when given ".local" address.

https://github.com/ruby/ruby/pull/1425

  Patch by @elct9620 [fix GH-1484]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2017-10-21 13:58:31 +00:00
Родитель 926103a958
Коммит db590b5d59
2 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -2603,7 +2603,7 @@ class Resolv
def each_address(name)
name = Resolv::DNS::Name.create(name)
return unless name.to_a.last == 'local'
return unless name.to_a.last.to_s == 'local'
super(name)
end

18
test/resolv/test_mdns.rb Normal file
Просмотреть файл

@ -0,0 +1,18 @@
# frozen_string_literal: false
require 'test/unit'
require 'resolv'
class TestResolvMDNS < Test::Unit::TestCase
def setup
end
def test_mdns_each_address
mdns = Resolv::MDNS.new
mdns.each_resource '_http._tcp.local', Resolv::DNS::Resource::IN::PTR do |r|
srv = mdns.getresource r.name, Resolv::DNS::Resource::IN::SRV
mdns.each_address(srv.target) do |result|
assert_not_nil(result)
end
end
end
end