Changeset 334


Ignore:
Timestamp:
05/09/12 22:24:27 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

Checkpoint updating export for reverse DNS. See #26.

  • Retrieve record IDs to track A+PTR (and possibly AAAA+PTR, eventually) records so we don't double-export them
  • Fix bug that snuck in to PTR export; $ttl, not a literal 'ttl'
  • Fix buglet in recursive call to _printrec_tiny for AAAA+PTR; forgot to pass $recflags
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r333 r334  
    39733973
    39743974  my $domsth = $dbh->prepare("SELECT domain_id,domain,status FROM domains WHERE status=1");
    3975   my $recsth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl ".
     3975  my $recsth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl,record_id ".
    39763976        "FROM records WHERE domain_id=?");
    39773977  $domsth->execute();
    39783978  while (my ($domid,$dom,$domstat) = $domsth->fetchrow_array) {
    39793979    $recsth->execute($domid);
    3980     while (my ($host,$type,$val,$dist,$weight,$port,$ttl) = $recsth->fetchrow_array) {
     3980    while (my ($host,$type,$val,$dist,$weight,$port,$ttl,$recid) = $recsth->fetchrow_array) {
     3981      next if $recflags{$recid};
    39813982##fixme:  need to store location in the db, and retrieve it here.
    39823983# temporarily hardcoded to empty so we can include it further down.
     
    39903991
    39913992      _printrec_tiny($datafile,'n',\%recflags,$dom,$host,$type,$val,$dist,$weight,$port,$ttl,$loc,$stamp);
     3993      $recflags{$recid} = 1;
    39923994
    39933995    } # while ($recsth)
     
    39953997
    39963998  my $revsth = $dbh->prepare("SELECT rdns_id,revnet,status FROM revzones WHERE status=1");
    3997   $recsth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl ".
     3999  $recsth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl,record_id ".
    39984000        "FROM records WHERE rdns_id=?");
    39994001  $revsth->execute();
    40004002  while (my ($revid,$revzone,$revstat) = $revsth->fetchrow_array) {
    40014003    $recsth->execute($revid);
    4002     while (my ($host,$type,$val,$dist,$weight,$port,$ttl) = $recsth->fetchrow_array) {
     4004    while (my ($host,$type,$val,$dist,$weight,$port,$ttl,$recid) = $recsth->fetchrow_array) {
     4005      next if $recflags{$recid};
    40034006##fixme:  need to store location in the db, and retrieve it here.
    40044007# temporarily hardcoded to empty so we can include it further down.
     
    40124015
    40134016      _printrec_tiny($datafile,'y',\%recflags,$revzone,$host,$type,$val,$dist,$weight,$port,$ttl,$loc,$stamp);
     4017      $recflags{$recid} = 1;
    40144018
    40154019    } # while ($recsth)
     
    41574161          print $datafile "^".
    41584162                _ZONE($val, 'ZONE', 'r', '.').($val->{isv6} ? '.ip6.arpa' : '.in-addr.arpa').
    4159                 ":$host:ttl:$stamp:$loc\n";
     4163                ":$host:$ttl:$stamp:$loc\n";
    41604164        }
    41614165
    41624166      } elsif ($type == 65280) { # A+PTR
     4167
     4168        print $datafile "=$host:$val:$ttl:$stamp:$loc\n";
     4169
    41634170      } elsif ($type == 65281) { # AAAA+PTR
    41644171
     
    41704177          $type = 12;
    41714178        }
    4172         _printrec_tiny($datafile,$revrec,$zone,$host,$type,$val,$dist,$weight,$port,$ttl,$loc,$stamp);
     4179        _printrec_tiny($datafile,$revrec,$recflags,$zone,$host,$type,$val,$dist,$weight,$port,$ttl,$loc,$stamp);
    41734180
    41744181      } elsif ($type == 65282) { # PTR template
Note: See TracChangeset for help on using the changeset viewer.