summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-20 10:19:59 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-20 10:19:59 +0000
commit00be14ac2cb658239c3f70a4c73bd8adbedb7f41 (patch)
treec7fa2ea539a061b4f8cf929500326581b6f21045 /lib
parentf37871204728b155f589bf6add2a58347116704b (diff)
Comment updates.
Diffstat (limited to 'lib')
-rw-r--r--lib/custodian/multiping.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/custodian/multiping.rb b/lib/custodian/multiping.rb
index a39e81b..b498f13 100644
--- a/lib/custodian/multiping.rb
+++ b/lib/custodian/multiping.rb
@@ -4,6 +4,13 @@ require 'socket'
require 'timeout'
+#
+# This class has methods to determine whether the target
+# of a hostname/IP address is IPv4 or IPv6.
+#
+# Assuming the address resolves to one of those two types
+# it can invoke on of /usr/bin/ping or /usr/bin/ping6 appropriately.
+#
class MultiPing
#
@@ -11,6 +18,9 @@ class MultiPing
#
attr_reader :hostname, :resolved
+ #
+ # Save the hostname away, resolve it if possible.
+ #
def initialize( hostname )
@hostname = hostname
@resolved = resolve_hostname( hostname )
@@ -18,14 +28,13 @@ class MultiPing
#
- #
+ # TODO: Use custodian/dnsutil now it exists.
#
def resolve_hostname( hostname )
res = nil
begin
timeout( 4 ) do
-
begin
Socket.getaddrinfo(hostname, 'echo').each do |a|
res = a[3]
@@ -96,6 +105,5 @@ class MultiPing
return false
end
-
end