Changeset 865


Ignore:
Timestamp:
09/20/22 17:50:30 (20 months ago)
Author:
Kris Deugau
Message:

/trunk

BIND export, unwinding dev saves, 17 of many many

  • Add %recflags ahead of zone loop(s)
  • Convert calls to and argument handling in printrec_bind() to use a reference to %recflags instead of @loclist
  • Add block for A+PTR template
  • Add stub block for AAAA+PTR template
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB/ExportBIND.pm

    r864 r865  
    4747  my $zonesth = $dnsdb->{dbh}->prepare("UPDATE revzones SET changed='n' WHERE rdns_id=?");
    4848  $revsth->execute();
     49
     50  my %recflags;  # need this to be independent for forward vs reverse zones, as they're not merged
     51
    4952  while (my ($revid,$revzone,$revstat,$changed,$defloc) = $revsth->fetchrow_array) {
    5053    my $cidr = NetAddr::IP->new($revzone);
     
    101104        $soasth->execute($revid);
    102105        my (@zsoa) = $soasth->fetchrow_array();
    103         printrec_bind(\%zonefiles, $zsoa[7], 'y', \@loclist, $revzone,
     106##fixme: do we even need @loclist passed in?
     107        printrec_bind(\%zonefiles, $zsoa[7], 'y', \%recflags, $revzone,
    104108          $zsoa[0],$zsoa[1],$zsoa[2],$zsoa[3],$zsoa[4],$zsoa[5],$zsoa[6],$zsoa[8],'');
    105109
     
    216220sub printrec_bind {
    217221  my $dnsdb = shift;
    218   my ($zonefiles, $recid, $revrec, $loclist, $zone, $host, $type, $val, $distance, $weight, $port, $ttl,
     222
     223#  my ($zonefiles, $recid, $revrec, $loclist, $zone, $host, $type, $val, $distance, $weight, $port, $ttl,
     224  my ($zonefiles, $recid, $revrec, $recflags, $zone, $host, $type, $val, $distance, $weight, $port, $ttl,
    219225        $loc, $stamp, $expires, $stampactive) = @_;
    220226
     
    335341    $$recflags{$val}++;
    336342    if ($revrec eq 'y') {
    337       printrec_bind($zonefiles, $recid, $revrec, $loclist, $zone, $host, 12, $val, $distance, $weight, $port, $ttl,
     343      printrec_bind($zonefiles, $recid, $revrec, $recflags, $zone, $host, 12, $val, $distance, $weight, $port, $ttl,
    338344       $loc, $stamp, $expires, $stampactive);
    339345#print {$zonefiles->{$loc}} "=$host:$val:$ttl:$stamp:$loc\n" or die $!;
     
    343349#        $loc, $stamp, $expires, $stampactive) = @_;
    344350    } else {
    345       printrec_bind($zonefiles, $recid, $revrec, $loclist, $zone, $host, 1, $val, $distance, $weight, $port, $ttl,
     351      printrec_bind($zonefiles, $recid, $revrec, $recflags, $zone, $host, 1, $val, $distance, $weight, $port, $ttl,
    346352       $loc, $stamp, $expires, $stampactive);
    347353    }
     
    415421  } # PTR template
    416422
     423  elsif ($type == 65283) { # A+PTR template
     424    $val = NetAddr::IP->new($val);
     425    # Just In Case.  An A+PTR should be impossible to add to a v6 revzone via API.
     426    return if $val->{isv6};
     427
     428    if ($val->masklen < 16) {
     429      foreach my $sub ($val->split(16)) {
     430        $self->__publish_subnet($sub, $recflags, $host, $zonefiles->{$loc}, $ttl, $stamp, $loc, $zone, 0);
     431      }
     432    } else {
     433      $self->__publish_subnet($val, $recflags, $host, $zonefiles->{$loc}, $ttl, $stamp, $loc, $zone, 0);
     434    }
     435  } # A+PTR template
     436 
     437  elsif ($type == 65284) { # AAAA+PTR template
     438    # Stub for completeness.  Could be exported to DNS software that supports
     439    # some degree of internal automagic in generic-record-creation
     440    # (eg http://search.cpan.org/dist/AllKnowingDNS/ )
     441  } # AAAA+PTR template
     442
    417443} # printrec_bind()
    418444
Note: See TracChangeset for help on using the changeset viewer.