Skip to content

Instantly share code, notes, and snippets.

@feyeleanor
Created August 14, 2012 15:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feyeleanor/3350413 to your computer and use it in GitHub Desktop.
Save feyeleanor/3350413 to your computer and use it in GitHub Desktop.
Ordering NAPTR records with Dnsruby
require 'rubygems'
require 'dnsruby'
include Dnsruby
$nameserver = Resolver.new
def dig domain, rrtype
search = $nameserver.query(domain, Types.send(rrtype))
if rrtype == :NAPTR
search.answer.sort_by { |a| [ a.order, a.preference ] }.each { |rr|
search.answer.delete rr
search.add_answer rr
}
end
search
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment