lib/wmap/utils/utils.rb
# Perform DNS query on a hostname.  Return the first resolved IP as a string
Perform DNS query on a hostname.  Return the first resolved IP as a string
Perform DNS query on a hostname . Return the first resolved IP as a string
def host_2_ip (hostname)
		puts "Perform DNS query on host: #{hostname}" if @verbose
		begin
			ips=Array.new
			if is_ip?(hostname)
				puts "No change - same IP is returned. " if @verbose
				return hostname.strip
			else
				ips=Resolv.getaddresses(hostname)
				if (ips.empty?) then
					puts "Failed to resolve #{hostname}" if @verbose
					return nil
				else
					puts "IP found: #{ips.first}" if @verbose
					return ips.first.strip
				end
			end
		rescue => ee
			puts "Exception on method host_2_ip for host #{hostname}: #{ee}" if @verbose
			return nil
		end
	end
def host_2_ip ( hostname ) puts "Perform DNS query on host: #{hostname}" if @verbose begin ips = Array . new if is_ip? ( hostname ) puts "No change - same IP is returned. " if @verbose return hostname . strip else ips = Resolv . getaddresses ( hostname ) if ( ips . empty? ) then puts "Failed to resolve #{hostname}" if @verbose return nil else puts "IP found: #{ips.first}" if @verbose return ips . first . strip end end rescue => ee puts "Exception on method host_2_ip for host #{hostname}: #{ee}" if @verbose return nil end end
Perform DNS query on a hostname.
Perform DNS query on a hostname .
hostname
<not_specific>