Changeset 870 for trunk/DNSDB


Ignore:
Timestamp:
09/28/22 15:56:15 (2 years ago)
Author:
Kris Deugau
Message:

/trunk

BIND export, unwinding dev saves, 22 of many many

  • Refine/tighten reverse zone export order
  • Note zone<->location relationship for future need
  • Forcibly include 'common' location in locations list
  • Minor cleanup for correctness in BIND configuration fragment
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB/ExportBIND.pm

    r869 r870  
    4343  # Fetch active zone list
    4444  my $revsth = $dnsdb->{dbh}->prepare("SELECT rdns_id,revnet,status,changed,default_location FROM revzones WHERE status=1 ".
    45         "ORDER BY masklen(revnet) DESC, rdns_id");
     45        "ORDER BY masklen(revnet),revnet DESC, rdns_id");
    4646  # Unflag changed zones, so we can maybe cache the export and not redo everything every time
    4747  my $zonesth = $dnsdb->{dbh}->prepare("UPDATE revzones SET changed='n' WHERE rdns_id=?");
     
    105105          open $zonefiles{$loc}, ">", $zfilepath;
    106106          printf {$zonefiles{$loc}} "; %s in view %s exported %s\n", $arpazone, $loc, scalar(localtime)
    107             or die "Error writing SOA [$zone, '$loc']: $!\n";;
    108         }
     107            or die "Error writing header [$zone, '$loc']: $!\n";;
     108          # tag the zonefile for publication in the view
     109          push @{$viewzones{$loc}}, $arpazone;
     110        } # foreach @loclist
    109111
    110112        # need to fetch this separately since the rest of the records all (should) have real IPs in val
     
    198200    open BINDCONF, ">", $tmpconf;
    199201
    200     foreach my $view (@{$viewlist}) {
     202    foreach my $view (@{$viewlist}, 'common') {
    201203#print Dumper($view);
    202204      print BINDCONF "view $view->{location} {\n";
     
    207209      # same as a BIND view with match-clients { any; };
    208210      if ($view->{iplist}) {
    209          print BINDCONF "  match-clients { ".join("; ", $view->iplist)."; };\n";
     211         print BINDCONF "  match-clients { ".join("; ", $view->{iplist})."; };\n";
    210212#         print "  match-clients { ".join("; ", split(/[\s,]+/, $view->{iplist}))."; };\n";
    211213      } else {
     
    217219        print qq(  zone "$zone" IN {\n\ttype master;\n\tnotify no;\n\tfile "db.$zone";\n  };\n);
    218220      }
     221      print BINDCONF "};\n\n";
    219222      print "};\n\n";
    220223    } # foreach @$viewlist
Note: See TracChangeset for help on using the changeset viewer.