Changeset 644


Ignore:
Timestamp:
06/11/14 14:52:25 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Add options to skip export of .0 and .255 IPs in template records.
Required tweaking calls to _printrec_tiny() and some of its inner subs
to pass the DNSDB object down to where the option is actually used.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r642 r644  
    219219                # 'all' (all IP values in any reverse zone view)
    220220                showrev_arpa    => 'none',
     221                # Two options for template record expansion:
     222                template_skip_0 => 0,   # publish .0 by default
     223                template_skip_255       => 0,   # publish .255 by default
    221224        );
    222225
     
    248251
    249252  # Several settings are booleans.  Handle multiple possible ways of setting them.
    250   for my $boolopt ('log_failures', 'force_refresh', 'lowercase', 'usecache') {
     253  for my $boolopt ('log_failures', 'force_refresh', 'lowercase', 'usecache',
     254        'template_skip_0', 'template_skip_255') {
    251255    if ($self->{$boolopt} ne '1' && $self->{$boolopt} ne '0') {
    252256      # true/false, on/off, yes/no all valid.
     
    17001704      $cfg->{lowercase}         = $1 if /^lowercase\s*=\s*([a-z01]+)/i;
    17011705      $cfg->{showrev_arpa}      = $1 if /^showrev_arpa\s*=\s*([a-z]+)/i;
     1706      $cfg->{template_skip_0}   = $1 if /^template_skip_0\s*=\s*([a-z01]+)/i;
     1707      $cfg->{template_skip_255} = $1 if /^template_skip_255\s*=\s*([a-z01]+)/i;
    17021708# not supported in dns.cgi yet
    17031709#      $cfg->{templatedir}      = $1 if m{^templatedir\s*=\s*([a-z0-9/_.-]+)}i;
     
    55545560        $soasth->execute($revid);
    55555561        my (@zsoa) = $soasth->fetchrow_array();
    5556         _printrec_tiny($zonefilehandle, $zsoa[7], 'y',\%recflags,$revzone,
     5562        $self->_printrec_tiny($zonefilehandle, $zsoa[7], 'y',\%recflags,$revzone,
    55575563          $zsoa[0],$zsoa[1],$zsoa[2],$zsoa[3],$zsoa[4],$zsoa[5],$zsoa[6],$zsoa[8],'');
    55585564
     
    55885594          }
    55895595
    5590           _printrec_tiny($zonefilehandle, $recid, 'y', \%recflags, $revzone,
     5596          $self->_printrec_tiny($zonefilehandle, $recid, 'y', \%recflags, $revzone,
    55915597            $host, $type, $val, $dist, $weight, $port, $ttl, $loc, $stamp, $expires, $stampactive);
    55925598
     
    56655671        $soasth->execute($domid);
    56665672        my (@zsoa) = $soasth->fetchrow_array();
    5667         _printrec_tiny($zonefilehandle, $zsoa[7], 'n',\%recflags,$dom,
     5673        $self->_printrec_tiny($zonefilehandle, $zsoa[7], 'n',\%recflags,$dom,
    56685674          $zsoa[0],$zsoa[1],$zsoa[2],$zsoa[3],$zsoa[4],$zsoa[5],$zsoa[6],$zsoa[8],'');
    56695675
     
    56875693          }
    56885694
    5689           _printrec_tiny($zonefilehandle, $recid, 'n', \%recflags,
     5695          $self->_printrec_tiny($zonefilehandle, $recid, 'n', \%recflags,
    56905696                $dom, $host, $type, $val, $dist, $weight, $port, $ttl, $loc, $stamp, $expires, $stampactive);
    56915697
     
    57365742# Utility sub for __export_tiny above
    57375743sub _printrec_tiny {
     5744  my $self = shift;
    57385745  my ($datafile, $recid, $revrec, $recflags, $zone, $host, $type, $val, $dist, $weight, $port, $ttl,
    57395746        $loc, $stamp, $expires, $stampactive) = @_;
     
    58405847##  forked process
    58415848  sub __publish_subnet {
     5849    my $obj = shift;    # *sigh*  need to pass in the DNSDB object so we can read a couple of options
    58425850    my $sub = shift;
    58435851    my $recflags = shift;
     
    58585866      # make as if we split the non-octet-aligned block into octet-aligned blocks as with SOA
    58595867      my $lastoct = (split /\./, $ip)[3];
    5860       next if $ip =~ /\.(0|255)$/; # && $self->{skip_net_0}
     5868      next if $ip =~ /\.0$/ && $obj->{template_skip_0};
     5869      next if $ip =~ /\.255$/ && $obj->{template_skip_255};
    58615870      next if $$recflags{$ip}; # && $self->{skip_bcast_255}
    58625871      $$recflags{$ip}++;
     
    60766085    # print both;  a dangling record is harmless, and impossible via web
    60776086    # UI anyway
    6078     _printrec_tiny($datafile,$revrec,$recflags,$zone,$host,28,$val,$dist,$weight,$port,$ttl,$loc,$stamp);
    6079     _printrec_tiny($datafile,$revrec,$recflags,$zone,$host,12,$val,$dist,$weight,$port,$ttl,$loc,$stamp);
     6087    $self->_printrec_tiny($datafile,$revrec,$recflags,$zone,$host,28,$val,$dist,$weight,$port,$ttl,$loc,$stamp);
     6088    $self->_printrec_tiny($datafile,$revrec,$recflags,$zone,$host,12,$val,$dist,$weight,$port,$ttl,$loc,$stamp);
    60806089##fixme: add a config flag to indicate use of the patch from http://www.fefe.de/dns/
    60816090# type 6 is for AAAA+PTR, type 3 is for AAAA
     
    60906099    if ($val->masklen <= 16) {
    60916100      foreach my $sub ($val->split(16)) {
    6092         __publish_subnet($sub, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 1);
     6101        $self->__publish_subnet($sub, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 1);
    60936102      }
    60946103    } else {
    6095       __publish_subnet($val, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 1);
     6104      $self->__publish_subnet($val, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 1);
    60966105    }
    60976106
     
    61046113    if ($val->masklen <= 16) {
    61056114      foreach my $sub ($val->split(16)) {
    6106         __publish_subnet($sub, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 0);
     6115        $self->__publish_subnet($sub, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 0);
    61076116      }
    61086117    } else {
    6109       __publish_subnet($val, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 0);
     6118      $self->__publish_subnet($val, $recflags, $host, $datafile, $ttl, $stamp, $loc, $zone, 0);
    61106119    }
    61116120
     
    61196128
    61206129    # All delegations need to create one or more NS records.  The NS record handler knows what to do.
    6121     _printrec_tiny($datafile,$recid,$revrec,$recflags,$zone,$host,$reverse_typemap{'NS'},
     6130    $self->_printrec_tiny($datafile,$recid,$revrec,$recflags,$zone,$host,$reverse_typemap{'NS'},
    61226131      $val,$dist,$weight,$port,$ttl,$loc,$stamp);
    61236132    if ($revrec eq 'y') {
  • trunk/dnsdb.conf

    r583 r644  
    4141#showrev_arpa = 0
    4242
     43# publish .0 IP when expanding a template pattern
     44#template_skip_0 = 0
     45
     46# publish .255 IP when expanding a template pattern
     47#template_skip_255 = 0
     48
    4349## General RPC options
    4450# may already be obsolete.  how do we want to run RPC requests?
Note: See TracChangeset for help on using the changeset viewer.