Created
April 22, 2015 21:00
-
-
Save rklemme/3691be310c67c4a596d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
ARGF.each do |line| | |
if /^\s*(\S+)\s+((?:\d{1,3}\.){3}\d{1,3})(?!\d)/ =~ line | |
host = $1 | |
listed_ip = $2 | |
begin | |
addrinfo = Socket::getaddrinfo(host, nil, :INET) | |
returned_ips = addrinfo.map {|a| a[3]} | |
puts "#{host}: Listed #{listed_ip} Returned IPs #{returned_ips.join ", "}." | |
rescue SocketError => e | |
$stderr.puts "Oops: #{e} for: #{host} #{listed_ip}" | |
end | |
else | |
$stderr.puts "Ignoring #{line}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment