Changeset 360


Ignore:
Timestamp:
07/09/12 17:51:58 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Checkpoint on tiny-import.pl

  • Handle wildcards sanely in the records that usefully support them. (mostly)
  • Handle TXT records in reverse zones
  • Properly put AAAA records in forward zones, not reverse zones
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tiny-import.pl

    r359 r360  
    125125    my $nodefer = shift || 0;
    126126
     127    $errstr = $rec;  # this way at least we have some idea what went <splat>
     128
    127129    if ($rec =~ /^=/) {
    128130      $cnt{APTR}++;
     
    155157      $host =~ s/^C//;
    156158      $host =~ s/\.$//;
     159      $host =~ s/^\\052/*/;
    157160      $ttl = 0 if !$ttl;
    158161      $stamp = '' if !$stamp;
     
    249252      $host =~ s/^\+//;
    250253      $host =~ s/\.$//;
     254      $host =~ s/^\\052/*/;
    251255      $ttl = 0 if !$ttl;
    252256      $stamp = '' if !$stamp;
     
    290294      $zone =~ s/^\@//;
    291295      $zone =~ s/\.$//;
     296      $zone =~ s/^\\052/*/;
    292297      $host =~ s/\.$//;
    293298      $host = "$host.mx.$zone" if $host !~ /\./;
     
    314319      my ($fqdn, $rdata, $ttl, $stamp, $loc) = split /:/, $rec, 5;
    315320      $fqdn =~ s/^'//;
     321      $fqdn =~ s/^\\052/*/;
    316322      _deoctal(\$rdata);
    317323      $ttl = 0 if !$ttl;
     
    320326      $loc = '' if $loc =~ /^:+$/;
    321327
    322       my $domid = DNSDB::_hostparent($dbh, $fqdn);
    323       if ($domid) {
    324         $recsth->execute($domid, 0, $fqdn, 16, $rdata, 0, 0, 0, $ttl);
    325       } else {
    326         push @deferred, $rec unless $nodefer;
     328      if ($fqdn =~ /\.arpa$/) {
     329        ($code,$msg) = DNSDB::_zone2cidr($fqdn);
     330        my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ($msg));
     331        $recsth->execute(0, $rparent, $rdata, 16, "$msg", 0, 0, 0, $ttl);
     332      } else {
     333        my $domid = DNSDB::_hostparent($dbh, $fqdn);
     334        if ($domid) {
     335          $recsth->execute($domid, 0, $fqdn, 16, $rdata, 0, 0, 0, $ttl);
     336        } else {
     337          push @deferred, $rec unless $nodefer;
     338        }
    327339      }
    328340
     
    383395
    384396      my (undef, $fqdn, $type, $rdata, $ttl, $stamp, $loc) = split /:/, $rec, 7;
     397      $fqdn =~ s/\.$//;
     398      $fqdn =~ s/^\\052/*/;
    385399      $ttl = 0 if !$ttl;
    386400      $stamp = '' if !$stamp;
     
    430444        my $val = NetAddr::IP->new(join(':', @v6));
    431445
    432         my ($rdns) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ("$val"));
    433         if ($rdns) {
    434           $recsth->execute(0, $rdns, $fqdn, 28, $val->addr, 0, 0, 0, $ttl);
     446        my $fparent = DNSDB::_hostparent($dbh, $fqdn);
     447        if ($fparent) {
     448          $recsth->execute($fparent, 0, $fqdn, 28, $val->addr, 0, 0, 0, $ttl);
    435449        } else {
    436450          push @deferred, $rec unless $nodefer;
Note: See TracChangeset for help on using the changeset viewer.