- Timestamp:
- 09/01/22 13:17:46 (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB/ExportBIND.pm
r848 r849 30 30 my $dbh = $self->{dbh}; 31 31 32 # to be a hash of views/locations, containing lists of zones 33 my %viewzones; 34 32 35 # allow for future exports of subgroups of records 33 my $viewlist = $ dnsdb->getLocList(curgroup => 1);36 my $viewlist = $self->getLocList(curgroup => 1); 34 37 35 # Write the view list to a configuration fragment 38 # Fetch active zone list 39 my $revsth = $self->{dbh}->prepare("SELECT rdns_id,revnet,status,changed,default_location FROM revzones WHERE status=1 ". 40 "ORDER BY masklen(revnet) DESC, rdns_id"); 41 # Unflag changed zones, so we can maybe cache the export and not redo everything every time 42 my $zonesth = $self->{dbh}->prepare("UPDATE revzones SET changed='n' WHERE rdns_id=?"); 43 $revsth->execute(); 44 while (my ($revid,$revzone,$revstat,$changed,$defloc) = $revsth->fetchrow_array) { 45 # fetch a list of views/locations present in the zone. we need to publish a file for each one. 46 # in the event that no locations are present (~~ $viewlist is empty), /%view collapses to nothing in the zone path 47 my (@loclist) = $self->{dbh}->selectrow_array("SELECT DISTINCT location FROM records WHERE rdns_id = ?", undef, $revid); 48 push @loclist, $defloc; 49 my $zonepath = $self->{bind_export_zone_path}; 50 my %zonefiles; # to be a list of file handles. 51 ##fixme: convert logical revzone into .arpa name 52 foreach my $loc (@loclist) { 53 local $zonepath =~ s/\%view/$loc/; 54 print "open $zonefiles{$loc}, $zonepath\n"; 55 } 56 57 } # revsth->fetch 58 59 60 # Write the view configuration last, because otherwise we have to be horribly inefficient 61 # at figuring out which zones are visible/present in which views 36 62 if ($viewlist) { 37 63 foreach my $view (@{$viewlist}) { … … 47 73 print " match-clients { ".join("; ", split(/[\s,]+/, $view->{iplist}))."; };\n"; 48 74 } else { 49 # print BINDCONF " match-clients { any; };\n" 50 print " match-clients { any; };\n" 75 # print BINDCONF " match-clients { any; };\n"; 76 print " match-clients { any; };\n"; 77 } 78 foreach my $zone (@{$viewzones{$view->{location}}}) { 79 ##fixme: notify settings, maybe per-zone? 80 print qq( zone "$zone" IN {\n\ttype master;\n\tnotify no;\n\tfile "db.$zone";\n };\n); 51 81 } 52 82 print "};\n\n"; -
trunk/dnsdb.conf
r798 r849 27 27 # the DB or read from the existing cache file. 28 28 #force_refresh = 1 29 30 ## BIND export options 31 #bind_export_zone_path = /var/named/zones/%view/db.%zone 29 32 30 33 ## DNS data template options
Note:
See TracChangeset
for help on using the changeset viewer.