summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-20 10:24:17 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-20 10:24:17 +0000
commitfc2f19c2e010313ccde01c28f4add41c5dfa940c (patch)
tree15c02fe425c69cc716e1f40c301c781f5d0adf98
parent00be14ac2cb658239c3f70a4c73bd8adbedb7f41 (diff)
Use the DNSUtil library, now we have it.
-rw-r--r--lib/custodian/multiping.rb30
1 files changed, 2 insertions, 28 deletions
diff --git a/lib/custodian/multiping.rb b/lib/custodian/multiping.rb
index b498f13..b800196 100644
--- a/lib/custodian/multiping.rb
+++ b/lib/custodian/multiping.rb
@@ -1,8 +1,6 @@
require 'getoptlong'
-require 'socket'
-require 'timeout'
-
+require 'custodian/dnsutil'
#
# This class has methods to determine whether the target
@@ -23,34 +21,10 @@ class MultiPing
#
def initialize( hostname )
@hostname = hostname
- @resolved = resolve_hostname( hostname )
- end
-
-
- #
- # 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]
- end
- rescue SocketError
- end
- end
- rescue Timeout::Error => e
- resolved = nil
- end
-
- res
+ @resolved = DNSUtil.hostname_to_ip( hostname )
end
-
#
# Return the resolved address
#