summaryrefslogtreecommitdiff
path: root/lib
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
commit73619298c7ff1334dcb7e566f05cd7112ff9e10c (patch)
tree15c02fe425c69cc716e1f40c301c781f5d0adf98 /lib
parent410202ad61110110f24ea86c5795bef7eb5c3d52 (diff)
Use the DNSUtil library, now we have it.
Diffstat (limited to 'lib')
-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
#