Created
December 1, 2011 19:44
-
-
Save afeld/1419298 to your computer and use it in GitHub Desktop.
check if custom domains valid
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
num_ok = 0 | |
users = User.where(:custom_domain => /\S/) | |
users.each do |u| | |
begin | |
records = Net::DNS::Resolver.start(u.custom_domain).answer | |
rescue Net::DNS::Resolver::NoResponseError | |
records = [] | |
end | |
record_found = records.any?{ |record| | |
(record.is_a?(Net::DNS::RR::A) && record.address.to_s == '50.16.219.219') || | |
(record.is_a?(Net::DNS::RR::CNAME) && record.cname == "#{u.username}.jux.com") | |
} | |
if record_found | |
puts "ok:\t#{u.custom_domain}" | |
num_ok += 1 | |
else | |
puts "fail:\t#{u.custom_domain}\t#{records.inspect}" | |
end | |
end | |
"#{num_ok}/#{users.size(true)}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment