summaryrefslogtreecommitdiff
path: root/lib/custodian/util/dns.rb
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2013-06-24 07:14:56 +0100
committerSteve Kemp <steve@steve.org.uk>2013-06-24 07:14:56 +0100
commit08e738f8c6606424dbc20152b18523fe6fcb6818 (patch)
treed8f97c2a7e6ff0afd8c7011f81394ba651d87d29 /lib/custodian/util/dns.rb
parent22bfca05cd9a089c1fabbdaab31fd2dad881fb4c (diff)
Use the global timeout-period for DNS lookups.
The rest of custodian will use the configuration file to read the timeout value (with a default of 30 seconds), but the DNS-lookups were hardwired to timeout after four seconds. This is now resolved; the DNS lookups will use the global timeout period too now.
Diffstat (limited to 'lib/custodian/util/dns.rb')
-rw-r--r--lib/custodian/util/dns.rb18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/custodian/util/dns.rb b/lib/custodian/util/dns.rb
index a26cc96..e04361d 100644
--- a/lib/custodian/util/dns.rb
+++ b/lib/custodian/util/dns.rb
@@ -1,5 +1,6 @@
+require 'custodian/settings'
require 'ipaddr'
require 'socket'
require 'timeout'
@@ -21,8 +22,15 @@ module Custodian
#
def DNS.ip_to_hostname( ip )
resolved = nil
+
+ #
+ # Get the timeout period.
+ #
+ settings = Custodian::Settings.instance()
+ period = settings.timeout()
+
begin
- timeout( 4 ) do
+ timeout( period ) do
begin
Socket.getaddrinfo(ip, 'echo').each do |a|
resolved = a[2] if ( a )
@@ -45,8 +53,14 @@ module Custodian
resolved = nil
+ #
+ # Get the timeout period.
+ #
+ settings = Custodian::Settings.instance()
+ period = settings.timeout()
+
begin
- timeout( 4 ) do
+ timeout( period ) do
begin
Socket.getaddrinfo(hostname, 'echo').each do |a|
resolved = a[3] if ( a )