diff --git a/Changes b/Changes index 8db56d5..7378c44 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for Perl extension NetAddr::IP +4.073 Sat Apr 5 09:32:11 PDT 2014 + add documentation about FQDN conversion and + an option to disable + 4.072 Mon Jan 27 11:59:58 PST 2014 modify Makefile.PL to bypass missing 'pod2text' diff --git a/IP.pm b/IP.pm index 25aa711..a0aa65a 100644 --- a/IP.pm +++ b/IP.pm @@ -37,7 +37,7 @@ @ISA = qw(Exporter NetAddr::IP::Lite); -$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.72 $ =~ /\d+/g) }; +$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.73 $ =~ /\d+/g) }; $rfc3021 = 0; @@ -65,6 +65,7 @@ :old_storable :old_nth :rfc3021 + :nofqdn ); NOTE: NetAddr::IP::Util has a full complement of network address @@ -101,6 +102,8 @@ FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:: = V4mask(); ::FFFF:FFFF = V4net(); + Will also return an ipV4 or ipV6 representation of a + resolvable Fully Qualified Domanin Name (FQDN). ###### DEPRECATED, will be remove in version 5 ############ @@ -614,6 +617,12 @@ 123456789012 a 'big' bcd number (bigger than perl likes) and Math::BigInt +A Fully Qualified Domain Name which returns an ipV4 address or an ipV6 +address, embodied in that order. This previously undocumented feature +may be disabled with: + + use NetAddr::IP::Lite ':nofqdn'; + If called with no arguments, 'default' is assumed. If called with an empty string as the argument, returns 'undef' diff --git a/Lite/Changes b/Lite/Changes index fca0bd0..249f513 100644 --- a/Lite/Changes +++ b/Lite/Changes @@ -1,5 +1,9 @@ Revision history for Perl extension NetAddr::IP::Lite +1.53 Sat Apr 5 09:32:11 PDT 2014 + add documentation about FQDN conversion and + an option to disable + 1.52 Mon Jan 27 11:59:58 PST 2014 modify Makefile.PL to bypass missing 'pod2text' diff --git a/Lite/Lite.pm b/Lite/Lite.pm index 50d4752..456337f 100644 --- a/Lite/Lite.pm +++ b/Lite/Lite.pm @@ -30,9 +30,9 @@ havegethostbyname2 ); -use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth $AUTOLOAD *Zero); +use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth $NoFQDN $AUTOLOAD *Zero); -$VERSION = do { my @r = (q$Revision: 1.52 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.53 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; require Exporter; @@ -67,6 +67,7 @@ :old_nth :upper :lower + :nofqdn ); my $ip = new NetAddr::IP::Lite '127.0.0.1'; @@ -93,6 +94,9 @@ FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:: = V4mask(); ::FFFF:FFFF = V4net(); + Will also return an ipV4 or ipV6 representation of a + resolvable Fully Qualified Domanin Name (FQDN). + =head1 INSTALLATION Un-tar the distribution in an appropriate directory and type: @@ -624,6 +628,12 @@ 123456789012 a 'big' bcd number (bigger than perl likes) and Math::BigInt +A Fully Qualified Domain Name which returns an ipV4 address or an ipV6 +address, embodied in that order. This previously undocumented feature +may be disabled with: + + use NetAddr::IP::Lite ':nofqdn'; + If called with no arguments, 'default' is assumed. If called with and empty string as the argument, 'undef' is returned; @@ -1002,12 +1012,12 @@ last; } # check for resolvable IPv4 hosts - elsif ($ip !~ /[^a-zA-Z0-9\.-]/ && ($tmp = gethostbyname(fillIPv4($ip))) && $tmp ne $_v4zero && $tmp ne $_zero ) { + elsif (! $NoFQDN && $ip !~ /[^a-zA-Z0-9\.-]/ && ($tmp = gethostbyname(fillIPv4($ip))) && $tmp ne $_v4zero && $tmp ne $_zero ) { $ip = ipv4to6($tmp); last; } # check for resolvable IPv6 hosts - elsif ($ip !~ /[^a-zA-Z0-9\.-]/ && havegethostbyname2() && ($tmp = naip_gethostbyname($ip))) { + elsif (! $NoFQDN && $ip !~ /[^a-zA-Z0-9\.-]/ && havegethostbyname2() && ($tmp = naip_gethostbyname($ip))) { $ip = $tmp; $isV6 = 1; last; @@ -1573,6 +1583,11 @@ NetAddr::IP::Util::upper(); @_ = grep { $_ ne ':upper' } @_; } + if (grep { $_ eq ':nofqdn' } @_) + { + $NoFQDN = 1; + @_ = grep { $_ ne ':nofqdn' } @_; + } NetAddr::IP::Lite->export_to_level(1, @_); } @@ -1586,6 +1601,7 @@ :old_nth :upper :lower + :nofqdn =head1 AUTHORS diff --git a/Lite/MANIFEST b/Lite/MANIFEST index b6f2fdd..1cc7edd 100644 --- a/Lite/MANIFEST +++ b/Lite/MANIFEST @@ -29,6 +29,7 @@ t/network.t t/new-nth.t t/new-num.t +t/nofqdn.t t/numeric.t t/old-nth.t t/old-num.t diff --git a/Lite/README b/Lite/README index 9c6b418..c687f17 100644 --- a/Lite/README +++ b/Lite/README @@ -11,6 +11,7 @@ :old_nth :upper :lower + :nofqdn ); my $ip = new NetAddr::IP::Lite '127.0.0.1'; @@ -37,6 +38,9 @@ FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:: = V4mask(); ::FFFF:FFFF = V4net(); + Will also return an ipV4 or ipV6 representation of a + resolvable Fully Qualified Domanin Name (FQDN). + INSTALLATION Un-tar the distribution in an appropriate directory and type: @@ -297,6 +301,12 @@ 123456789012 a 'big' bcd number (bigger than perl likes) and Math::BigInt + A Fully Qualified Domain Name which returns an ipV4 address or an + ipV6 address, embodied in that order. This previously undocumented + feature may be disabled with: + + use NetAddr::IP::Lite ':nofqdn'; + If called with no arguments, 'default' is assumed. If called with and empty string as the argument, 'undef' is @@ -480,6 +490,7 @@ :old_nth :upper :lower + :nofqdn AUTHORS Luis E. Muñoz , Michael Robinton diff --git a/Lite/t/nofqdn.t b/Lite/t/nofqdn.t new file mode 100644 index 0000000..91ab975 --- /dev/null +++ b/Lite/t/nofqdn.t @@ -0,0 +1,29 @@ + + +use NetAddr::IP::Lite + +$| = 1; + +print "1..2\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + + +my $ip = new NetAddr::IP::Lite('arin.net'); +if (defined $ip) { + print "ok $test # Skipped, resolved $ip\n"; + $test++; +} else { + print "ok $test # Skipped, resolver not working\n"; + $test++; +} + +import NetAddr::IP::Lite qw(:nofqdn); + +$ip = new NetAddr::IP::Lite('arin.net'); +print "unexpected response with :nofqdn\nnot " + if defined $ip; +&ok; diff --git a/MANIFEST b/MANIFEST index 9753d71..0faa44e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -70,6 +70,7 @@ Lite/t/network.t Lite/t/new-nth.t Lite/t/new-num.t +Lite/t/nofqdn.t Lite/t/numeric.t Lite/t/old-nth.t Lite/t/old-num.t diff --git a/META.yml b/META.yml index 3d5e58c..146fe7d 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- #YAML:1.0 name: NetAddr-IP -version: 4.072 +version: 4.073 abstract: Manages IPv4 and IPv6 addresses and subnets license: ~ author: