Skip to content

ptr_check method #20

@askreet

Description

@askreet

I would have submitted a code fix, but I'm just not that confident in my knowledge of DNS.

def check_ptr(str)
      IPAddr.new str
    rescue
      raise ArgumentError, "PTR section not valid"
end

It appears that it's attempting to verify the last field is an IP address, which is not what a PTR record is. I'm not able to use the following code, for example, should I be?

irb(main):081:0> x="114.206.37.66.in-addr.arpa. 3600 IN PTR www.inforonics.com."
=> "114.206.37.66.in-addr.arpa. 3600 IN PTR www.inforonics.com."
irb(main):082:0> rr = Net::DNS::RR.new(x)
Net::DNS::RR::ArgumentError: PTR section not valid
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/net-dns-0.6.1/lib/net/dns/rr/ptr.rb:27:in check_ptr' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/net-dns-0.6.1/lib/net/dns/rr/ptr.rb:52:insubclass_new_from_string'
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/net-dns-0.6.1/lib/net/dns/rr.rb:282:in new_from_string' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/net-dns-0.6.1/lib/net/dns/rr.rb:131:ininitialize'
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/net-dns-0.6.1/lib/net/dns/rr.rb:360:in send' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/net-dns-0.6.1/lib/net/dns/rr.rb:360:innew'
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/net-dns-0.6.1/lib/net/dns/rr.rb:280:in new_from_string' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/net-dns-0.6.1/lib/net/dns/rr.rb:131:ininitialize'
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/net-dns-0.6.1/lib/net/dns/rr.rb:360:in send' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/net-dns-0.6.1/lib/net/dns/rr.rb:360:innew'
from (irb):82

My goal is to parse out the PTR record value. (In this case www.inforonics.com.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions