ruby-changes:28590
From: naruse <ko1@a...>
Date: Sat, 11 May 2013 19:51:34 +0900 (JST)
Subject: [ruby-changes:28590] naruse:r40642 (trunk): Simplify test with Socket.getifaddrs
naruse 2013-05-11 19:51:22 +0900 (Sat, 11 May 2013) New Revision: 40642 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40642 Log: Simplify test with Socket.getifaddrs Modified files: trunk/test/rinda/test_rinda.rb Index: test/rinda/test_rinda.rb =================================================================== --- test/rinda/test_rinda.rb (revision 40641) +++ test/rinda/test_rinda.rb (revision 40642) @@ -532,14 +532,11 @@ end https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L532 module RingIPv6 def prepare_ipv6(r) - Socket.ip_address_list.any? do |addrinfo| - if /%(?<ifname>\w+)\z/ =~ addrinfo.ip_address - next if /\Alo/ =~ ifname - _family, _port, _flowinfo, _addr, scope_id = - addrinfo.to_sockaddr.unpack("s!S!La16L") - r.multicast_interface = scope_id - return - end + Socket.getifaddrs.each do |ifaddr| + next unless ifaddr.addr.ipv6_linklocal? + next if ifaddr.name[0, 2] == "lo" + r.multicast_interface = ifaddr.ifindex + return end skip 'IPv6 not available' end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/