From 73619298c7ff1334dcb7e566f05cd7112ff9e10c Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Tue, 20 Nov 2012 10:24:17 +0000 Subject: Use the DNSUtil library, now we have it. --- lib/custodian/multiping.rb | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) (limited to 'lib/custodian/multiping.rb') 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 # -- cgit v1.2.1