Changeset 601


Ignore:
Timestamp:
03/25/14 17:29:06 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Update AXFR import reverse zone name detection:

  • allow IPv6 CIDR "zones" instead of requiring the .arpa name
  • IPv4, leading-octet (eg 192.168.42 will be treated as 192.168.42.0/24)
  • IPv6, leading-quad format similar to the IPv4 leading-octet above
  • Return the zone name we couldn't interpret, mainly for RPC or API callers as the web UI should be pretty clear on which errors/warnings go with with requested zone name
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r600 r601  
    46474647# Handles sub-octet v4 zones in the format specified in the Cricket Book, 2nd Ed, p217-218
    46484648
    4649   if ($zone =~ m{(?:\.arpa\.?|/\d+)$}) {
     4649  if ($zone =~ m{(?:\.arpa\.?|/\d+|^[\d.]+|^[a-fA-F0-9:]+)$}) {
    46504650    # we seem to have a reverse zone
    46514651    $rev = 'y';
     
    46604660      $cidr = NetAddr::IP->new($zone) or return ('FAIL',"$zone is not a valid CIDR block");
    46614661      $zone = _ZONE($cidr, 'ZONE.in-addr.arpa', 'r', '.');
     4662    } elsif ($zone =~ /^[\d.]+$/) {
     4663      # v4 revzone, leading-octet format
     4664      my $mask = 32;
     4665      while ($zone !~ /^\d+\.\d+\.\d+\.\d+$/) {
     4666        $zone .= '.0';
     4667        $mask -= 8;
     4668      }
     4669      $zone .= "/$mask";
     4670      $cidr = NetAddr::IP->new($zone) or return ('FAIL',"$zone is not a valid CIDR block");
     4671      $zone = _ZONE($cidr, 'ZONE.in-addr.arpa', 'r', '.');
    46624672    } elsif ($zone =~ m|^[a-fA-F\d:]+/\d+$|) {
    46634673      # v6 revzone, CIDR netblock
     
    46654675      return ('FAIL', "$zone is not a nibble-aligned block") if $cidr->masklen % 4 != 0;
    46664676      $zone = _ZONE($cidr, 'ZONE.ip6.arpa', 'r', '.');
     4677    } elsif ($zone =~ /^[a-fA-F\d:]+$/) {
     4678      # v6 revzone, leading-group format
     4679      $zone =~ s/::$//;
     4680      my $mask = 128;
     4681      while ($zone !~ /^(?:[a-fA-F\d]{1,4}:){7}[a-fA-F\d]$/) {
     4682        $zone .= ":0";
     4683        $mask -= 16;
     4684      }
     4685      $zone .= "/$mask";
     4686      $cidr = NetAddr::IP->new($zone) or return ('FAIL',"$zone is not a valid CIDR block");
     4687      $zone = _ZONE($cidr, 'ZONE.ip6.arpa', 'r', '.');
    46674688    } else {
    46684689      # there is. no. else!
    4669       return ('FAIL', "Unknown zone name format");
    4670     }
     4690      return ('FAIL', "Unknown zone name format '$zone'");
     4691    }
     4692
     4693    # several places this can be triggered from;  better to do it once.
     4694    $warnmsg .= "Apparent sub-/64 IPv6 reverse zone\n" if $cidr->masklen > 64;
    46714695
    46724696    # quick check to start to see if we've already got one
Note: See TracChangeset for help on using the changeset viewer.