Changeset 791
- Timestamp:
- 09/27/19 11:21:32 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tiny-import.pl
r777 r791 122 122 $dnsdb->{logusername} = $dnsdb->{logusername}."/tiny-import.pl"; 123 123 $dnsdb->{logfullname} = $dnsdb->{logusername} if !$dnsdb->{logfullname}; 124 $dnsdb->{logfullname} = $dnsdb->{logfullname}."/tiny-import.pl"; 124 125 125 126 $dbh->{AutoCommit} = 0; … … 132 133 133 134 foreach my $file (@ARGV) { 135 my %filecount; 136 my $logentry = "Import records from $file: "; 134 137 eval { 135 import(file => $file); 136 # import(file => $file, nosoa => 1); 138 import(file => $file, cnt => \%filecount); 139 if (%filecount) { 140 foreach (sort keys %filecount) { 141 $logentry .= "$_ $filecount{$_}, "; 142 $cnt{$_} += $filecount{$_}; 143 } 144 $logentry =~ s/[\s,]+$//; 145 $dnsdb->_log(group_id => $importcfg{group}, entry => $logentry); 146 } 137 147 $dbh->rollback if $importcfg{trial}; 138 148 $dbh->commit unless $importcfg{trial}; … … 146 156 147 157 # print summary count of record types encountered 148 foreach ( keys %cnt) {158 foreach (sort keys %cnt) { 149 159 print " $_ $cnt{$_}\n"; 150 160 } … … 155 165 our %args = @_; 156 166 my $flatfile = $args{file}; 167 my $filecnt = $args{cnt}; 157 168 my @fpath = split '/', $flatfile; 158 169 $fpath[$#fpath] = ".$fpath[$#fpath]"; … … 186 197 chomp; 187 198 s/\s*$//; 188 my $recstat = recslurp($_ );199 my $recstat = recslurp($_, $filecnt); 189 200 $ok++ if $recstat; 190 201 if ($importcfg{rw}) { … … 322 333 sub recslurp { 323 334 my $rec = shift; 335 my $filecnt = shift; 324 336 my $nodefer = shift || 0; 325 337 my $impok = 1; … … 329 341 330 342 if ($rec =~ /^=/) { 331 $ cnt{APTR}++;343 $filecnt->{'A+PTR'}++; 332 344 333 345 ##fixme: do checks like this for all types … … 384 396 385 397 } elsif ($rec =~ /^C/) { 386 $ cnt{CNAME}++;398 $filecnt->{CNAME}++; 387 399 388 400 my ($host,$targ,$ttl,$stamp,$loc) = split /:/, $rec, 5; … … 429 441 430 442 } elsif ($rec =~ /^\&/) { 431 $ cnt{NS}++;443 $filecnt->{NS}++; 432 444 433 445 my ($zone,$ip,$ns,$ttl,$stamp,$loc) = split /:/, $rec, 6; … … 471 483 472 484 } elsif ($rec =~ /^\^/) { 473 $ cnt{PTR}++;485 $filecnt->{PTR}++; 474 486 475 487 my ($rip,$host,$ttl,$stamp,$loc) = split /:/, $rec, 5; … … 521 533 522 534 } elsif ($rec =~ /^\+/) { 523 $ cnt{A}++;535 $filecnt->{A}++; 524 536 525 537 my ($host,$ip,$ttl,$stamp,$loc) = split /:/, $rec, 5; … … 558 570 559 571 } elsif ($rec =~ /^Z/) { 560 $ cnt{SOA}++;572 $filecnt->{SOA}++; 561 573 562 574 my ($zone,$master,$contact,$serial,$refresh,$retry,$expire,$minttl,$ttl,$stamp,$loc) = split /:/, $rec, 11; … … 610 622 611 623 } elsif ($rec =~ /^\@/) { 612 $ cnt{MX}++;624 $filecnt->{MX}++; 613 625 614 626 my ($zone,$ip,$host,$dist,$ttl,$stamp,$loc) = split /:/, $rec, 7; … … 641 653 642 654 } elsif ($rec =~ /^'/) { 643 $ cnt{TXT}++;655 $filecnt->{TXT}++; 644 656 645 657 my ($fqdn, $rdata, $ttl, $stamp, $loc) = split /:/, $rec, 5; … … 672 684 673 685 } elsif ($rec =~ /^\./) { 674 $ cnt{NSASOA}++;686 $filecnt->{NSASOA}++; 675 687 676 688 my ($fqdn, $ip, $ns, $ttl, $stamp, $loc) = split /:/, $rec, 6; … … 746 758 747 759 } elsif ($rec =~ /^\%/) { 748 $ cnt{VIEWS}++;760 $filecnt->{VIEWS}++; 749 761 750 762 # unfortunate that we don't have a guaranteed way to get a description on these. :/ … … 765 777 766 778 } elsif ($rec =~ /^:/) { 767 $ cnt{NCUST}++;779 $filecnt->{NCUST}++; 768 780 # Big section. Since tinydns can publish anything you can encode properly, but only provides official 769 781 # recognition and handling for the core common types, this must deal with the leftovers. … … 930 942 931 943 } else { 932 $ cnt{other}++;944 $filecnt->{other}++; 933 945 print " $_\n"; 934 946 }
Note:
See TracChangeset
for help on using the changeset viewer.