Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 116529
Status: rejected
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: Clement.Law [...] Sophos.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: Gabor Kiss <gabor.kiss [...] sophos.com>
Subject: Changes Interface for RR.pm
Date: Wed, 27 Jul 2016 14:04:22 +0000
To: "bug-Net-DNS [...] rt.cpan.org" <bug-Net-DNS [...] rt.cpan.org>
From: Clement Law <Clement.Law [...] Sophos.com>
Hello, Whilst trying to get an IP address of a hostname, I’m using the following (pseudo)code: … use Net::DNS; use Data::Dumper; my $Dns = new Net::DNS::Resolver(); my $Query = $Dns->query(“somehostname”, ‘A’) my($Resource) = $Query->answer() print Dumper($Resource); … …and I get the following structure in Ubuntu Lucid: $VAR1 = bless( { 'rdlength' => 4, 'ttl' => 900, 'name' => 'xxxxxx.yyyyyy.zzzzzz', 'address' => '10.123.123.12', 'class' => 'IN', 'type' => 'A', 'rdata' => ' �� ' }, 'Net::DNS::RR::A' ); Where rdata is raw data 4 bytes in length the corresponds to the plain text in the address field. But in CentOS 7 and Ubuntu Xenial, I get: $VAR1 = bless( { 'owner' => bless( { 'label' => [], 'origin' => bless( { 'label' => [ 'xxxxxx', 'yyyyyy', 'zzzzzz' ] }, 'Net::DNS::DomainName' ) }, 'Net::DNS::DomainName1035' ), 'address' => ' �� ', 'rdlength' => 4, 'class' => 1, 'ttl' => 900, 'type' => 1 }, 'Net::DNS::RR::A' ); I’m just looking for some documentation and changelogs as to why these changes were made. As far as I can see, in the latter example, the string information has been stripped out, meaning that I have to use the RR::rdstring() and RR:string() methods to extract the information I need. I believe the former behaviour is present in Ubuntu Trusty, too. Just for reference, the version of Net::DNS::RR.pm in Ubuntu Lucid is 758 (DNS.pm is 796) In CentOS 7, it is 1094 (DNS.pm is (DNS.pm is 1095) In Ubuntu Xenial, it is 1282 (DNS.pm is 1285) Many thanks, Clement Law Show quoted text
________________________________ Sophos Ltd, a company registered in England and Wales, number 2096520, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom
From: rwfranks [...] acm.org
On Wed Jul 27 10:04:25 2016, Clement.Law@Sophos.com wrote: Show quoted text
> Hello, > > Whilst trying to get an IP address of a hostname, I’m using the > following (pseudo)code: > > … > use Net::DNS; > use Data::Dumper; > my $Dns = new Net::DNS::Resolver(); > my $Query = $Dns->query(“somehostname”, ‘A’) > my($Resource) = $Query->answer() > print Dumper($Resource); > … > > …and I get the following structure in Ubuntu Lucid: > > $VAR1 = bless( { > 'rdlength' => 4, > 'ttl' => 900, > 'name' => 'xxxxxx.yyyyyy.zzzzzz', > 'address' => '10.123.123.12', > 'class' => 'IN', > 'type' => 'A', > 'rdata' => ' > �� ' > }, 'Net::DNS::RR::A' ); > > Where rdata is raw data 4 bytes in length the corresponds to the plain > text in the address field. > > But in CentOS 7 and Ubuntu Xenial, I get: > > $VAR1 = bless( { > 'owner' => bless( { > 'label' => [], > 'origin' => bless( { > 'label' => [ > 'xxxxxx', > 'yyyyyy', > 'zzzzzz' > ] > }, > 'Net::DNS::DomainName' ) > }, 'Net::DNS::DomainName1035' ), > 'address' => ' > �� ', > 'rdlength' => 4, > 'class' => 1, > 'ttl' => 900, > 'type' => 1 > }, 'Net::DNS::RR::A' ); > > I’m just looking for some documentation and changelogs as to why these > changes were made. As far as I can see, in the latter example, the > string information has been stripped out, meaning that I have to use > the RR::rdstring() and RR:string() methods to extract the information > I need. > > I believe the former behaviour is present in Ubuntu Trusty, too. > > Just for reference, the version of Net::DNS::RR.pm in Ubuntu Lucid is > 758 (DNS.pm is 796) > In CentOS 7, it is 1094 (DNS.pm is (DNS.pm is 1095) > In Ubuntu Xenial, it is 1282 (DNS.pm is 1285) > > Many thanks, > > Clement Law > > ________________________________ > > Sophos Ltd, a company registered in England and Wales, number 2096520, > The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United > Kingdom
The whole point of the object-oriented paradigm is to separate the logical behaviour of abstract objects from the internal state representation and implementation mechanics. The internal state of an object is assumed to be observable ONLY using the published methods. The public interface to the RR object is defined by the documented behaviour of class and instance methods of the RR base and 59 derived RR subtypes. Apart from the philosophical objections, attempts to extract useful information by direct reference to private data structures are doomed to failure for two reasons: 1) The data structure changes dynamically depending on how the object was created and subsequent method call history. Logically identical instances can have different internal representations. 2) There is no obligation on developers to abstain from making changes to internal data representation. There are some helpful examples in <http://search.cpan.org/~nlnetlabs/Net-DNS-1.06/lib/Net/DNS.pm>