Changeset 356 for trunk


Ignore:
Timestamp:
06/29/12 17:48:31 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Checkpoint: tiny-import.pl

  • Add warning to header
  • Remove development print in NS segment
  • Fill in PTR stub (See #26)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tiny-import.pl

    r355 r356  
    1919##
    2020
     21# WARNING:  This is NOT a heavy-duty validator;  it is assumed that the data
     22# being imported is more or less sane.  Only minor structural validation will
     23# be done to weed out the most broken records.
     24
    2125use strict;
    2226use warnings;
     
    188192      if ($zone =~ /\.arpa$/) {
    189193        ($code,$msg) = DNSDB::_zone2cidr($zone);
    190         print "revzone $msg from $zone\n";
    191194        my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >>= ?", undef, ("$msg"));
    192195##fixme, in concert with the CNAME check for same;  automagically
     
    210213    } elsif ($rec =~ /^\^/) {
    211214      $cnt{PTR}++;
     215
     216      my ($rip,$host,$ttl,$stamp,$loc) = split /:/, $rec, 5;
     217      $rip =~ s/^\^//;
     218      $rip =~ s/\.$//;
     219      $ttl = 0 if !$ttl;
     220      $stamp = '' if !$stamp;
     221      $loc = '' if !$loc;
     222      $loc = '' if $loc =~ /^:+$/;
     223      my $rparent;
     224      if (my ($i, $z) = ($rip =~ /^(\d+)\.(\d+-(?:\d+\.){4}in-addr.arpa)$/) ) {
     225        ($code,$msg) = DNSDB::_zone2cidr($z);
     226        # Exact matches only, because we're in a sub-/24 delegation
     227##fixme:  flag the type of delegation (range, subnet-with-dash, subnet-with-slash)
     228# somewhere so we can recover it on export.  probably best to do that in the revzone data.
     229        ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet = ?", undef, ("$msg"));
     230        $z =~ s/^[\d-]+//;
     231        ($code,$msg) = DNSDB::_zone2cidr("$i.$z");      # Get the actual IP and normalize
     232      } else {
     233        ($code,$msg) = DNSDB::_zone2cidr($rip);
     234        ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ("$msg"));
     235      }
     236      if ($rparent) {
     237        $recsth->execute(0, $rparent, $host, 12, $msg->addr, 0, 0, 0, $ttl);
     238      } else {
     239        push @deferred, $rec unless $nodefer;
     240      }
    212241
    213242    } elsif ($rec =~ /^\+/) {
Note: See TracChangeset for help on using the changeset viewer.