Created
August 14, 2012 15:47
-
-
Save feyeleanor/3350413 to your computer and use it in GitHub Desktop.
Ordering NAPTR records with Dnsruby
This file contains hidden or 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 '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