Skip to content

Instantly share code, notes, and snippets.

@bogdan
Created June 6, 2016 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogdan/f0715a22b26584c53d24fe5f5bfb78a4 to your computer and use it in GitHub Desktop.
Save bogdan/f0715a22b26584c53d24fe5f5bfb78a4 to your computer and use it in GitHub Desktop.
def custom_domain_up_new?
return false unless custom_domain.present?
Resolv::DNS.open do |dns|
dns.timeouts = 2
# Querying each type of record individually
# Because ANY query may not return all required types
{
Resolv::DNS::Resource::IN::CNAME => /(talkable|curebit)\.com$/,
Resolv::DNS::Resource::IN::NS => /ns-\d+.awsdns-\d+.com$/,
}.any? do |type, regex|
dns.getresources(custom_domain, type).any? do |record|
record.name.to_s =~ regex
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment