Changeset 822


Ignore:
Timestamp:
12/04/20 13:30:21 (4 years ago)
Author:
Kris Deugau
Message:

/trunk

Fifteenth sampled iteration of bind-import

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bind-import

    r821 r822  
    3131
    3232my $dnsdb = new DNSDB;
     33
    3334my $dryrun = 0;
    3435
     
    140141    if ($zid) {
    141142      die "zone $origzone already present, not merging records\n";
    142 #print "dbg: skip add domain\n";
     143#print "dbg: skip add revzone\n";
    143144#      $zname = new NetAddr::IP $zname;
    144145#      $zname = DNSDB::_ZONE($zname, 'ZONE', 'r', '.').($zname->{isv6} ? '.ip6.arpa' : '.in-addr.arpa');
     
    150151    $zid = $dnsdb->domainID($zname,':ANY:');
    151152    if ($zid) {
    152       die "zone $origzone already present, not merging records\n";
     153#      die "zone $origzone already present, not merging records\n";
    153154#print "dbg: skip add domain\n";
    154155    }
    155     ($zid) = $dnsdb->{dbh}->selectrow_array("INSERT INTO domains (domain,group_id,status,default_location,zserial) VALUES (?,?,?,?,?) RETURNING domain_id",
    156         undef, ($zname, $group, $status, $location, $serial));
     156#    ($zid) = $dnsdb->{dbh}->selectrow_array("INSERT INTO domains (domain,group_id,status,default_location,zserial) VALUES (?,?,?,?,?) RETURNING domain_id",
     157#       undef, ($zname, $group, $status, $location, $serial));
    157158
    158159  }
     
    205206
    206207$i++;
    207 last if $i > 17;
     208#last if $i > 17;
    208209#print "line $i: ($rec)\n";
    209210    if (my ($macro,$mdetail) = ($rec =~ /^\s*\$(TTL|ORIGIN|INCLUDE|GENERATE)\s+(.+)/) ) {
     
    562563#    unless ($dryrun) {
    563564      my ($code, $msg);
    564       if ($rev eq 'n') {
    565         ($code,$msg) = $dnsdb->addRec('n', $rev, $zid, \$curlabel, \$itype, \$rdata, $ttl,
    566           $location, undef, undef, $distance, $weight, $port);
    567       } else {
    568         ($code,$msg) = $dnsdb->addRec('y', $rev, $zid, \$rdata, \$itype, \$curlabel, $ttl,
    569           $location, undef, undef, $distance, $weight, $port);
    570       }
     565
     566# swap curlabel/rdata for revzones, because our internal metastorage only knows about "host" and "val"
     567# keep the originals Just In Case(TM)
     568$curlabel =~ s/\.$//;   # dnsadmin doesn't store trailing dots
     569my $inshost = $curlabel;
     570my $insval = $rdata;
     571if ($rev eq 'y') {
     572  $inshost = $rdata;
     573  $insval = $curlabel;
     574}
     575print "dbg: maybeip next ($insval)\n";
     576my $addr = NetAddr::IP->new($insval) if DNSDB::_maybeip(\$insval);
     577my $fields;
     578my @vallist;
     579
     580($code,$msg) = $validators{$itype}($dnsdb, defrec => 'n', revrec => $rev, id => $zid,
     581        host => \$inshost, rectype => \$itype, val => \$insval, addr => $addr,
     582        dist => \$distance, port => \$port, weight => \$weight,
     583        fields => \$fields, vallist => \@vallist);
     584
     585# Add standard common fields
     586$fields .= "host,type,val,ttl,".DNSDB::_recparent('n',$rev);
     587push @vallist, ($inshost,$itype,$insval,$ttl,$zid);
     588
     589my $vallen = '?'.(',?'x$#vallist);
     590
     591print "INSERT INTO records ($fields) VALUES ($vallen);\n".join("','", @vallist)."\n";
     592
     593#      if ($rev eq 'n') {
     594#        ($code,$msg) = $dnsdb->addRec('n', $rev, $zid, \$curlabel, \$itype, \$rdata, $ttl,
     595#          $location, undef, undef, $distance, $weight, $port);
     596#      } else {
     597#        ($code,$msg) = $dnsdb->addRec('y', $rev, $zid, \$rdata, \$itype, \$curlabel, $ttl,
     598#          $location, undef, undef, $distance, $weight, $port);
     599#      }
    571600      print "$code: $msg\n" if $code ne 'OK';
    572601#    }
Note: See TracChangeset for help on using the changeset viewer.