230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# File 'lib/inspec/resources/host.rb', line 230
def resolve_with_dig(hostname)
addresses = []
cmd = inspec.command("dig +short A #{hostname}")
cmd.stdout.lines.each do |line|
matched = line.chomp.match(Resolv::IPv4::Regex)
addresses << matched.to_s unless matched.nil?
end
cmd = inspec.command("dig +short AAAA #{hostname}")
cmd.stdout.lines.each do |line|
matched = line.chomp.match(Resolv::IPv6::Regex)
addresses << matched.to_s unless matched.nil?
end
addresses.empty? ? nil : addresses
end
|