Skip to content

Commit

Permalink
import Net::DNS 0.65 from CPAN
Browse files Browse the repository at this point in the history
git-cpan-module: Net::DNS
git-cpan-version: 0.65
git-cpan-authorid: OLAF
  • Loading branch information
Olaf Kolkman authored and schwern committed Dec 7, 2009
1 parent 6e921af commit 40368c0
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 55 deletions.
18 changes: 15 additions & 3 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
$Id: Changes 768 2008-12-30 16:19:04Z olaf $ -*-text-*-
$Id: Changes 795 2009-01-26 17:28:44Z olaf $ -*-text-*-


**** 0.65 January 26, 2009

Fix rt.cpan.org #41076

When the AAAA object was constructed with new_from_hash with an
address containing the "::" shorthand notation normalization was
not done properly.

Fix rt.cpan.org #42375

Typo in Win32.pm Registry root.



Revision history for Net::DNS
=============================
**** 0.64 December 30, 2008

Feature rt.cpan.org #36656
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ t/05-rr-sshfp.t
t/05-rr-txt.t
t/05-rr-unknown.t
t/05-rr.t
t/05-rr-various.t
t/06-update.t
t/07-misc.t
t/08-online.t
Expand Down
39 changes: 24 additions & 15 deletions META.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
# https://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Net-DNS
version: 0.64
version_from: lib/Net/DNS.pm
installdirs: site
--- #YAML:1.0
name: Net-DNS
version: 0.65
abstract: Perl DNS resolver module
author:
- Olaf Kolkman <[email protected]>
license: unknown
distribution_type: module
configure_requires:
ExtUtils::MakeMaker: 0
requires:
Digest::HMAC_MD5: 1
Digest::MD5: 2.12
IO::Socket: 0
MIME::Base64: 2.11
Net::IP: 1.2
Test::More: 0.18

distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.30
Digest::HMAC_MD5: 1
Digest::MD5: 2.12
IO::Socket: 0
MIME::Base64: 2.11
Net::IP: 1.2
Test::More: 0.18
no_index:
directory:
- t
- inc
generated_by: ExtUtils::MakeMaker version 6.48
meta-spec:
url: https://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
6 changes: 3 additions & 3 deletions lib/Net/DNS.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

package Net::DNS;
#
# $Id: DNS.pm 762 2008-12-24 09:30:57Z olaf $
# $Id: DNS.pm 796 2009-01-26 17:30:18Z olaf $
#
use strict;

Expand Down Expand Up @@ -48,8 +48,8 @@ BEGIN {



$VERSION = '0.64';
$SVNVERSION = (qw$LastChangedRevision: 762 $)[1];
$VERSION = '0.65';
$SVNVERSION = (qw$LastChangedRevision: 796 $)[1];



Expand Down
70 changes: 42 additions & 28 deletions lib/Net/DNS/RR/AAAA.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package Net::DNS::RR::AAAA;
#
# $Id: AAAA.pm 388 2005-06-22 10:06:05Z olaf $
# $Id: AAAA.pm 795 2009-01-26 17:28:44Z olaf $
#
use strict;
BEGIN {
Expand All @@ -10,7 +10,7 @@ BEGIN {
use vars qw(@ISA $VERSION);

@ISA = qw(Net::DNS::RR);
$VERSION = (qw$LastChangedRevision: 388 $)[1];
$VERSION = (qw$LastChangedRevision: 795 $)[1];

sub new {
my ($class, $self, $data, $offset) = @_;
Expand All @@ -24,24 +24,52 @@ sub new {

sub new_from_string {
my ($class, $self, $string) = @_;
$self->{"address"}=$string;
bless $self, $class;
return $self->_normalize_AAAA();
}

sub rdatastr {
my $self = shift;

return $self->{"address"} || '';
}

sub rr_rdata {
my $self = shift;
my $rdata = "";
$self->_normalize_AAAA();
if (exists $self->{"address"}) {
my @addr = split(/:/, $self->{"address"});
$rdata .= pack("n8", map { hex $_ } @addr);
}

return $rdata;
}




sub _normalize_AAAA {
my $self=shift();
return $self->{"address"} if $self->{normalized};

my $string=$self->{"address"};
if ($string) {
my @addr;

# IPv4 mapped
# I think this is correct, per RFC 1884 Sections 2.2 & 2.4.4.
if ($string =~ /^(.*):(\d+)\.(\d+)\.(\d+)\.(\d+)$/) {
my ($front, $a, $b, $c, $d) = ($1, $2, $3, $4, $5);
$string = $front . sprintf(":%x:%x",
($a << 8 | $b),
($c << 8 | $d));
}

if ($string =~ /^(.*)::(.*)$/) {
}elsif($string =~ /^(.*)::(.*)$/) {
my ($front, $back) = ($1, $2);
my @front = split(/:/, $front);
my @back = split(/:/, $back);
my $fill = 8 - (@front ? $#front + 1 : 0)
- (@back ? $#back + 1 : 0);
- (@back ? $#back + 1 : 0);
my @middle = (0) x $fill;
@addr = (@front, @middle, @back);
}
Expand All @@ -51,30 +79,16 @@ sub new_from_string {
@addr = ((0) x (8 - @addr), @addr);
}
}

$self->{"address"} = sprintf("%x:%x:%x:%x:%x:%x:%x:%x",
map { hex $_ } @addr);
}

return bless $self, $class;
}

sub rdatastr {
my $self = shift;

return $self->{"address"} || '';
}

sub rr_rdata {
my $self = shift;
my $rdata = "";

if (exists $self->{"address"}) {
my @addr = split(/:/, $self->{"address"});
$rdata .= pack("n8", map { hex $_ } @addr);
}

return $rdata;
$self->{"normalized"}=1;
return $self;




}

1;
Expand Down
8 changes: 4 additions & 4 deletions lib/Net/DNS/Resolver/Win32.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package Net::DNS::Resolver::Win32;
#
# $Id: Win32.pm 756 2008-12-22 21:32:51Z olaf $
# $Id: Win32.pm 795 2009-01-26 17:28:44Z olaf $
#

use strict;
Expand All @@ -9,14 +9,14 @@ use vars qw(@ISA $VERSION);
use Net::DNS::Resolver::Base ();

@ISA = qw(Net::DNS::Resolver::Base);
$VERSION = (qw$LastChangedRevision: 756 $)[1];
$VERSION = (qw$LastChangedRevision: 795 $)[1];

use Win32::IPHelper;
use Win32::Registry;
use Data::Dumper;
sub init {

my $debug=1;
my $debug=0;
my ($class) = @_;

my $defaults = $class->defaults;
Expand Down Expand Up @@ -61,7 +61,7 @@ sub init {

my ($resobj, %keys);

my $root = 'SYSTEM\CurrentControlSet\Services\Tcplp\Parameters';
my $root = 'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters';
my $opened_registry =1;
unless ($main::HKEY_LOCAL_MACHINE->Open($root, $resobj)) {
# Didn't work, maybe we are on 95/98/Me?
Expand Down
40 changes: 40 additions & 0 deletions t/05-rr-various.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# $Id: 05-rr-various.t 795 2009-01-26 17:28:44Z olaf $ -*-perl-*-
# Contains a number of additional test for RR related functionality


use Test::More;
use strict;
use Net::DNS;
use vars qw( $HAS_DNSSEC $HAS_DLV $HAS_NSEC3 $HAS_NSEC3PARAM);


plan tests => 4;


is ( Net::DNS::stripdot ('foo\\\\\..'),'foo\\\\\.', "Stripdot does its magic in precense of escapes test 1");
is ( Net::DNS::stripdot ('foo\\\\\.'),'foo\\\\\.', "Stripdot does its magic in precense of escapes test 2");



# rt.cpan.org 41071
my $pkt1 = Net::DNS::Packet->new('e3.example.com','AAAA','IN');
$pkt1->push( answer => Net::DNS::RR->new(
name => 'e3.example.com',
type => 'AAAA',
address => 'CAFE:BABE::1'
));
my $pkt2 = Net::DNS::Packet->new( \$pkt1->data );
is(($pkt1->answer)[0]->string,($pkt2->answer)[0]->string,"New from string and new from hash creation ");

is(($pkt1->answer)[0]->address,"cafe:babe:0:0:0:0:0:1","Lets have cafe:babe:0:0:0:0:0:1");




#--------------
#
# Some test that test on appropriate normalization of internal storage
# when using new_from_hash



2 changes: 1 addition & 1 deletion t/09-tkey.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id: 09-tkey.t 616 2006-10-18 09:15:48Z olaf $ -*-perl-*-
# $Id: 09-tkey.t 795 2009-01-26 17:28:44Z olaf $ -*-perl-*-

use Test::More tests => 7;
use strict;
Expand Down
2 changes: 1 addition & 1 deletion t/99-cleanup.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id: 99-cleanup.t 745 2008-12-18 22:42:46Z olaf $ -*-perl-*-
# $Id: 99-cleanup.t 795 2009-01-26 17:28:44Z olaf $ -*-perl-*-
use Test::More;
plan tests => 1;

Expand Down

0 comments on commit 40368c0

Please sign in to comment.