From 925ebf966e49045556b94befe0dd4d36863350af Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Wed, 4 Mar 2015 10:01:41 +0000 Subject: Allow tests to be qualified IPv4/IPv6-only. Via "ipv6_only" and "IPv4_only" --- lib/custodian/protocoltest/tcp.rb | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'lib/custodian/protocoltest/tcp.rb') diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb index 7bceeac..3fd4129 100644 --- a/lib/custodian/protocoltest/tcp.rb +++ b/lib/custodian/protocoltest/tcp.rb @@ -72,7 +72,6 @@ module Custodian # @host = line.split( /\s+/)[0] - # # Is this test inverted? # @@ -176,6 +175,21 @@ module Custodian # end + # + # Both types? + # + do_ipv6 = true + do_ipv4 = true + + # + # Allow the test to disable one/both + # + if ( @line =~ /ipv4_only/ ) + do_ipv6 = false + end + if ( @line =~ /ipv6_only/ ) + do_ipv4 = false + end # @@ -186,10 +200,15 @@ module Custodian timeout( period ) do Resolv::DNS.open do |dns| - ress = dns.getresources(host, Resolv::DNS::Resource::IN::A) - ress.map { |r| ips.push( r.address.to_s ) } - ress = dns.getresources(host, Resolv::DNS::Resource::IN::AAAA) - ress.map { |r| ips.push( r.address.to_s ) } + + if ( do_ipv4 ) + ress = dns.getresources(host, Resolv::DNS::Resource::IN::A) + ress.map { |r| ips.push( r.address.to_s ) } + end + if ( do_ipv6 ) + ress = dns.getresources(host, Resolv::DNS::Resource::IN::AAAA) + ress.map { |r| ips.push( r.address.to_s ) } + end end end rescue Timeout::Error => e -- cgit v1.2.1