From 4c1c2b7f0786a681f8421635c4c0e118b29b9384 Mon Sep 17 00:00:00 2001 From: Vincent Magnin Date: Thu, 30 Apr 2020 11:26:28 +0200 Subject: [PATCH] replace Net::DNS::ZoneFile::Fast with Net::DNS::ZoneFile --- bin/perldeps.pl | 4 ++-- import/import_bind_zones.pl | 9 +++++---- lib/Netdot/Model/Zone.pm | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/perldeps.pl b/bin/perldeps.pl index 475386d3a..a93a6ca7f 100755 --- a/bin/perldeps.pl +++ b/bin/perldeps.pl @@ -62,8 +62,8 @@ {cpan=>'Text::ParseWords', apt=>'', rpm=>''}, {cpan=>'Carp::Assert', apt=>'libcarp-assert-perl', rpm=>'perl-Carp-Assert'}, {cpan=>'Digest::SHA', apt=> 'libdigest-sha-perl', rpm=>'perl-Digest-SHA1'}, - {apt=> 'libssl-dev', rpm=>'openssl-devel'}, # needed by Net::DNS::ZoneFile::Fast - {cpan=>'Net::DNS::ZoneFile::Fast', apt=> 'dnssec-tools', rpm=>''}, + {apt=> 'libssl-dev', rpm=>'openssl-devel'}, # needed by Net::DNS::ZoneFile + {cpan=>'Net::DNS::ZoneFile', apt=> 'libnet-dns-perl', rpm=>'perl-Net-DNS'}, {cpan=>'Socket6', apt=> 'libsocket6-perl', rpm=>'perl-Socket6'}, {cpan=>'XML::Simple', apt=>'libxml-simple-perl', rpm=>'perl-XML-Simple'}, {apt=>'snmp'}, diff --git a/import/import_bind_zones.pl b/import/import_bind_zones.pl index 834c753fb..5ccdb0e4d 100755 --- a/import/import_bind_zones.pl +++ b/import/import_bind_zones.pl @@ -4,7 +4,7 @@ # use lib "<>"; use Netdot::Model; -use Net::DNS::ZoneFile::Fast; +use Net::DNS::ZoneFile; use Getopt::Long qw(:config no_ignore_case bundling); use BIND::Config::Parser; use strict; @@ -146,11 +146,12 @@ sub import_zone { (-e $file && -f $file) || die "File $file does not exist or is not a regular file\n"; print "Importing zone file: $file\n"; - my $rrs = Net::DNS::ZoneFile::Fast::parse(file=>"$file",origin=>$domain); + my $zonefile = new Net::DNS::ZoneFile($file, $domain); + my @rrs = $zonefile->read; my $nzone; - foreach my $rr ( @$rrs ){ + foreach my $rr ( @rrs ){ if ( $rr->type eq 'SOA' ){ my $name = $rr->name; $name =~ s/\.$//; @@ -181,7 +182,7 @@ sub import_zone { } } - $nzone->import_records(rrs => $rrs, + $nzone->import_records(rrs => \@rrs, update_ptrs => $self{update_ptrs}, ); } diff --git a/lib/Netdot/Model/Zone.pm b/lib/Netdot/Model/Zone.pm index 353bdcd53..af161308d 100644 --- a/lib/Netdot/Model/Zone.pm +++ b/lib/Netdot/Model/Zone.pm @@ -3,7 +3,7 @@ package Netdot::Model::Zone; use base 'Netdot::Model'; use warnings; use strict; -use Net::DNS::ZoneFile::Fast; +use Net::DNS::ZoneFile; my $logger = Netdot->log->get_logger('Netdot::Model::DNS'); @@ -651,9 +651,9 @@ sub import_records { if ( $argv{text } ){ eval { - my $zone_content = $argv{text}; + my $zone_content = '$ORIGIN ' . $domain. "\n" . $argv{text}; $zone_content =~ s/\r\n/\n/g; - $rrs = Net::DNS::ZoneFile::Fast::parse(text=>$zone_content, origin=>$domain); + $rrs = Net::DNS::ZoneFile->parse( $zone_content ); }; if ( my $e = $@ ){ $self->throw_user("Error parsing Zone data: $e")