diff options
author | Steve Kemp <steve@steve.org.uk> | 2015-03-04 10:01:41 +0000 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2015-03-04 10:01:41 +0000 |
commit | c5aaa93450b75268a72a992ef39aca10dba7ee88 (patch) | |
tree | d142e7b95b111f5fb0d1201fff484c21524bb941 /lib/custodian | |
parent | 0a0b5ac9f25fc00ff2fed56c40241c3da9ba3037 (diff) |
Allow tests to be qualified IPv4/IPv6-only.
Via "ipv6_only" and "IPv4_only"
Diffstat (limited to 'lib/custodian')
-rw-r--r-- | lib/custodian/protocoltest/ping.rb | 30 | ||||
-rw-r--r-- | lib/custodian/protocoltest/tcp.rb | 29 |
2 files changed, 49 insertions, 10 deletions
diff --git a/lib/custodian/protocoltest/ping.rb b/lib/custodian/protocoltest/ping.rb index 8f3911d..37722c2 100644 --- a/lib/custodian/protocoltest/ping.rb +++ b/lib/custodian/protocoltest/ping.rb @@ -117,17 +117,37 @@ module Custodian # + # 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 + + # # OK if it didn't look like an IP address then attempt to # look it up, as both IPv4 and IPv6. - # + # begin 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 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 |