- Timestamp:
- 09/01/22 17:49:59 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB/ExportBIND.pm
r849 r850 36 36 my $viewlist = $self->getLocList(curgroup => 1); 37 37 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 38 44 # Fetch active zone list 39 45 my $revsth = $self->{dbh}->prepare("SELECT rdns_id,revnet,status,changed,default_location FROM revzones WHERE status=1 ". … … 43 49 $revsth->execute(); 44 50 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 45 62 # fetch a list of views/locations present in the zone. we need to publish a file for each one. 46 63 # in the event that no locations are present (~~ $viewlist is empty), /%view collapses to nothing in the zone path 47 64 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; 49 66 my $zonepath = $self->{bind_export_zone_path}; 50 67 my %zonefiles; # to be a list of file handles. 51 68 ##fixme: convert logical revzone into .arpa name 52 69 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; 76 print "open zonefile for '$loc', '$zonepath'\n"; 55 77 } 78 79 $soasth->execute($revid); 80 my (@zsoa) = $soasth->fetchrow_array(); 56 81 57 82 } # revsth->fetch
Note:
See TracChangeset
for help on using the changeset viewer.