Changeset 850 for trunk/DNSDB


Ignore:
Timestamp:
09/01/22 17:49:59 (2 years ago)
Author:
Kris Deugau
Message:

/trunk

BIND export, unwinding dev saves, 3 of many many

  • Set up SOA and general record retrieval statement handles
  • Prepare possible caching pathname
  • Extend zone file pathname assembly/generation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB/ExportBIND.pm

    r849 r850  
    3636  my $viewlist = $self->getLocList(curgroup => 1);
    3737
     38  my $soasth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl,record_id,location ".
     39        "FROM records WHERE rdns_id=? AND type=6");
     40  my $recsth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl,record_id,location,extract(epoch from stamp),expires,stampactive ".
     41        "FROM records WHERE rdns_id=? AND NOT type=6 ".
     42        "ORDER BY masklen(inetlazy(val)) DESC, inetlazy(val)");
     43
    3844  # Fetch active zone list
    3945  my $revsth = $self->{dbh}->prepare("SELECT rdns_id,revnet,status,changed,default_location FROM revzones WHERE status=1 ".
     
    4349  $revsth->execute();
    4450  while (my ($revid,$revzone,$revstat,$changed,$defloc) = $revsth->fetchrow_array) {
     51    my $tmpzone = NetAddr::IP->new($revzone);
     52    my $zfile = $tmpzone->network->addr."-".$tmpzone->masklen;
     53#    my $cachefile = "$self->{exportcache}/$zfile";
     54#    my $tmpcache = "$self->{exportcache}/tmp.$zfile.$$";
     55    my $tmpcache = "tmp.$zfile.$$";      # safety net.  don't overwrite a previous known-good file
     56
     57##fixme:  convert logical revzone into .arpa name?  maybe take a slice of showrev_arpa?
     58##fixme:  need to bodge logical non-octet-boundary revzones into octet-boundary revzones
     59##fixme:  do we do cache files?  views balloon the file count stupidly
     60
     61
    4562    # fetch a list of views/locations present in the zone.  we need to publish a file for each one.
    4663    # in the event that no locations are present (~~ $viewlist is empty), /%view collapses to nothing in the zone path
    4764    my (@loclist) = $self->{dbh}->selectrow_array("SELECT DISTINCT location FROM records WHERE rdns_id = ?", undef, $revid);
    48     push @loclist, $defloc;
     65    push @loclist, $defloc unless grep /$defloc/, @loclist;
    4966    my $zonepath = $self->{bind_export_zone_path};
    5067    my %zonefiles;  # to be a list of file handles.
    5168##fixme:  convert logical revzone into .arpa name
    5269    foreach my $loc (@loclist) {
    53       local $zonepath =~ s/\%view/$loc/;
    54 print "open $zonefiles{$loc}, $zonepath\n";
     70      my $zfilepath = $zonepath;
     71      $zonepath =~ s/\%view/$loc/;
     72      $zonepath =~ s/\%zone/$revzone/;
     73      # Just In Case(TM)
     74      $zonepath =~ s,[^\w./-],_,g;
     75      #open $zonefiles{$loc}, ">", $zfilepath;
     76print "open zonefile for '$loc', '$zonepath'\n";
    5577    }
     78
     79    $soasth->execute($revid);
     80    my (@zsoa) = $soasth->fetchrow_array();
    5681
    5782  } # revsth->fetch
Note: See TracChangeset for help on using the changeset viewer.