Changeset 372 for trunk/tiny-import.pl
- Timestamp:
- 08/01/12 18:19:03 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tiny-import.pl
r363 r372 68 68 open FLAT, "<$flatfile"; 69 69 70 our $recsth = $dbh->prepare("INSERT INTO records (domain_id,rdns_id,host,type,val,distance,weight,port,ttl ) ".71 " VALUES (?,?,?,?,?,?,?,?,? )");70 our $recsth = $dbh->prepare("INSERT INTO records (domain_id,rdns_id,host,type,val,distance,weight,port,ttl,location) ". 71 " VALUES (?,?,?,?,?,?,?,?,?,?)"); 72 72 73 73 my %deleg; … … 77 77 next if /^\s*$/; 78 78 chomp; 79 s/\s*$//; 79 80 recslurp($_); 80 81 } … … 187 188 my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ($ip)); 188 189 if ($fparent && $rparent) { 189 $recsth->execute($fparent, $rparent, $host, 65280, $ip, 0, 0, 0, $ttl );190 $recsth->execute($fparent, $rparent, $host, 65280, $ip, 0, 0, 0, $ttl, $loc); 190 191 } else { 191 192 push @deferred, $rec unless $nodefer; … … 207 208 ($code,$msg) = DNSDB::_zone2cidr($host); 208 209 my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ($msg)); 209 $recsth->execute(0, $rparent, $targ, 5, $msg->addr, 0, 0, 0, $ttl );210 $recsth->execute(0, $rparent, $targ, 5, $msg->addr, 0, 0, 0, $ttl, $loc); 210 211 211 212 ##fixme: automagically convert manually maintained sub-/24 delegations … … 218 219 my $fparent = DNSDB::_hostparent($dbh, $host); 219 220 if ($fparent) { 220 $recsth->execute($fparent, 0, $host, 5, $targ, 0, 0, 0, $ttl );221 $recsth->execute($fparent, 0, $host, 5, $targ, 0, 0, 0, $ttl, $loc); 221 222 } else { 222 223 push @deferred, $rec unless $nodefer; … … 245 246 # if !$rparent; 246 247 if ($rparent) { 247 $recsth->execute(0, $rparent, $ns, 2, $msg, 0, 0, 0, $ttl );248 $recsth->execute(0, $rparent, $ns, 2, $msg, 0, 0, 0, $ttl, $loc); 248 249 } else { 249 250 push @deferred, $rec unless $nodefer; … … 252 253 my $fparent = DNSDB::_hostparent($dbh, $zone); 253 254 if ($fparent) { 254 $recsth->execute($fparent, 0, $zone, 2, $ns, 0, 0, 0, $ttl );255 $recsth->execute($fparent, 0, $ns, 2, $ip, 0, 0, 0, $ttl ) if $ip;255 $recsth->execute($fparent, 0, $zone, 2, $ns, 0, 0, 0, $ttl, $loc); 256 $recsth->execute($fparent, 0, $ns, 2, $ip, 0, 0, 0, $ttl, $loc) if $ip; 256 257 } else { 257 258 push @deferred, $rec unless $nodefer; … … 283 284 } 284 285 if ($rparent) { 285 $recsth->execute(0, $rparent, $host, 12, $msg->addr, 0, 0, 0, $ttl );286 $recsth->execute(0, $rparent, $host, 12, $msg->addr, 0, 0, 0, $ttl, $loc); 286 287 } else { 287 288 push @deferred, $rec unless $nodefer; … … 302 303 my $domid = DNSDB::_hostparent($dbh, $host); 303 304 if ($domid) { 304 $recsth->execute($domid, 0, $host, 1, $ip, 0, 0, 0, $ttl );305 $recsth->execute($domid, 0, $host, 1, $ip, 0, 0, 0, $ttl, $loc); 305 306 } else { 306 307 push @deferred, $rec unless $nodefer; … … 323 324 $dbh->do("INSERT INTO revzones (revnet,group_id,status) VALUES (?,1,1)", undef, ($msg)); 324 325 my ($rdns) = $dbh->selectrow_array("SELECT currval('revzones_rdns_id_seq')"); 325 $recsth->execute(0, $rdns, "$contact:$master", 6, "$refresh:$retry:$expire:$minttl", 0, 0, 0, $ttl );326 $recsth->execute(0, $rdns, "$contact:$master", 6, "$refresh:$retry:$expire:$minttl", 0, 0, 0, $ttl, $loc); 326 327 } else { 327 328 $dbh->do("INSERT INTO domains (domain,group_id,status) VALUES (?,1,1)", undef, ($zone)); 328 329 my ($domid) = $dbh->selectrow_array("SELECT currval('domains_domain_id_seq')"); 329 $recsth->execute($domid, 0, "$contact:$master", 6, "$refresh:$retry:$expire:$minttl", 0, 0, 0, $ttl );330 $recsth->execute($domid, 0, "$contact:$master", 6, "$refresh:$retry:$expire:$minttl", 0, 0, 0, $ttl, $loc); 330 331 } 331 332 … … 350 351 my $domid = DNSDB::_hostparent($dbh, $zone); 351 352 if ($domid) { 352 $recsth->execute($domid, 0, $zone, 15, $host, $dist, 0, 0, $ttl);353 $recsth->execute($domid, 0, $host, 1, $ip, 0, 0, 0, $ttl ) if $ip;353 $recsth->execute($domid, 0, $zone, 15, $host, $dist, 0, 0, $ttl, $loc); 354 $recsth->execute($domid, 0, $host, 1, $ip, 0, 0, 0, $ttl, $loc) if $ip; 354 355 } else { 355 356 push @deferred, $rec unless $nodefer; … … 371 372 ($code,$msg) = DNSDB::_zone2cidr($fqdn); 372 373 my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ($msg)); 373 $recsth->execute(0, $rparent, $rdata, 16, "$msg", 0, 0, 0, $ttl );374 $recsth->execute(0, $rparent, $rdata, 16, "$msg", 0, 0, 0, $ttl, $loc); 374 375 } else { 375 376 my $domid = DNSDB::_hostparent($dbh, $fqdn); 376 377 if ($domid) { 377 $recsth->execute($domid, 0, $fqdn, 16, $rdata, 0, 0, 0, $ttl );378 $recsth->execute($domid, 0, $fqdn, 16, $rdata, 0, 0, 0, $ttl, $loc); 378 379 } else { 379 380 push @deferred, $rec unless $nodefer; … … 402 403 ($rdns) = $dbh->selectrow_array("SELECT currval('revzones_rdns_id_seq')"); 403 404 # this would probably make a lot more sense to do hostmaster.$config{admindomain} 404 $recsth->execute(0, $rdns, "hostmaster.$fqdn:$ns", 6, "16384:2048:1048576:2560", 0, 0, 0, "2560" );405 } 406 $recsth->execute(0, $rdns, $ns, 2, "$msg", 0, 0, 0, $ttl );405 $recsth->execute(0, $rdns, "hostmaster.$fqdn:$ns", 6, "16384:2048:1048576:2560", 0, 0, 0, "2560", $loc); 406 } 407 $recsth->execute(0, $rdns, $ns, 2, "$msg", 0, 0, 0, $ttl, $loc); 407 408 ##fixme: (?) implement full conversion of tinydns . records? 408 409 # -> problem: A record for NS must be added to the appropriate *forward* zone, not the reverse … … 420 421 $dbh->do("INSERT INTO domains (domain,group_id,status) VALUES (?,1,1)", undef, ($fqdn)); 421 422 ($domid) = $dbh->selectrow_array("SELECT currval('domains_domain_id_seq')"); 422 $recsth->execute($domid, 0, "hostmaster.$fqdn:$ns", 6, "16384:2048:1048576:2560", 0, 0, 0, "2560" );423 } 424 $recsth->execute($domid, 0, $fqdn, 2, $ns, 0, 0, 0, $ttl );425 $recsth->execute($domid, 0, $ns, 1, $ip, 0, 0, 0, $ttl ) if $ip;423 $recsth->execute($domid, 0, "hostmaster.$fqdn:$ns", 6, "16384:2048:1048576:2560", 0, 0, 0, "2560", $loc); 424 } 425 $recsth->execute($domid, 0, $fqdn, 2, $ns, 0, 0, 0, $ttl, $loc); 426 $recsth->execute($domid, 0, $ns, 1, $ip, 0, 0, 0, $ttl, $loc) if $ip; 426 427 } 427 428 … … 429 430 } elsif ($rec =~ /^\%/) { 430 431 $cnt{VIEWS}++; 432 433 # unfortunate that we don't have a guaranteed way to get a description on these. :/ 434 my ($loc,$cnet) = split /:/, $rec, 2; 435 $loc =~ s/^\%//; 436 if (my ($iplist) = $dbh->selectrow_array("SELECT iplist FROM locations WHERE location = ?", undef, ($loc))) { 437 if ($cnet) { 438 $iplist .= ",$cnet"; 439 $dbh->do("UPDATE locations SET iplist = ? WHERE location = ?", undef, ($iplist, $loc)); 440 } else { 441 # hmm. spit out a warning? if we already have entries for $loc, adding a null 442 # entry will almost certainly Do The Wrong Thing(TM) 443 } 444 } else { 445 $cnet = '' if !$cnet; # de-nullify 446 $dbh->do("INSERT INTO locations (location,iplist,description) VALUES (?,?,?)", undef, ($loc, $cnet, $loc)); 447 } 431 448 432 449 } elsif ($rec =~ /^:/) { … … 471 488 my $domid = DNSDB::_hostparent($dbh, $fqdn); 472 489 if ($domid) { 473 $recsth->execute($domid, 0, $fqdn, 33, $target, $prio, $weight, $port, $ttl ) if $domid;490 $recsth->execute($domid, 0, $fqdn, 33, $target, $prio, $weight, $port, $ttl, $loc) if $domid; 474 491 } else { 475 492 push @deferred, $rec unless $nodefer; … … 488 505 my $fparent = DNSDB::_hostparent($dbh, $fqdn); 489 506 if ($fparent) { 490 $recsth->execute($fparent, 0, $fqdn, 28, $val->addr, 0, 0, 0, $ttl );507 $recsth->execute($fparent, 0, $fqdn, 28, $val->addr, 0, 0, 0, $ttl, $loc); 491 508 } else { 492 509 push @deferred, $rec unless $nodefer; … … 501 518 my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ($msg)); 502 519 if ($rparent) { 503 $recsth->execute(0, $rparent, $txtstring, 16, "$msg", 0, 0, 0, $ttl );520 $recsth->execute(0, $rparent, $txtstring, 16, "$msg", 0, 0, 0, $ttl, $loc); 504 521 } else { 505 522 push @deferred, $rec unless $nodefer; … … 508 525 my $domid = DNSDB::_hostparent($dbh, $fqdn); 509 526 if ($domid) { 510 $recsth->execute($domid, 0, $fqdn, 16, $txtstring, 0, 0, 0, $ttl );527 $recsth->execute($domid, 0, $fqdn, 16, $txtstring, 0, 0, 0, $ttl, $loc); 511 528 } else { 512 529 push @deferred, $rec unless $nodefer; … … 527 544 my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ($msg)); 528 545 if ($rparent) { 529 $recsth->execute(0, $rparent, "$email $txtrec", 17, "$msg", 0, 0, 0, $ttl );546 $recsth->execute(0, $rparent, "$email $txtrec", 17, "$msg", 0, 0, 0, $ttl, $loc); 530 547 } else { 531 548 push @deferred, $rec unless $nodefer; … … 534 551 my $domid = DNSDB::_hostparent($dbh, $fqdn); 535 552 if ($domid) { 536 $recsth->execute($domid, 0, $fqdn, 17, "$email $txtrec", 0, 0, 0, $ttl );553 $recsth->execute($domid, 0, $fqdn, 17, "$email $txtrec", 0, 0, 0, $ttl, $loc); 537 554 } else { 538 555 push @deferred, $rec unless $nodefer; … … 549 566 my $domid = DNSDB::_hostparent($dbh, $fqdn); 550 567 if ($domid) { 551 $recsth->execute($domid, 0, $fqdn, 44, $sshfp, 0, 0, 0, $ttl );568 $recsth->execute($domid, 0, $fqdn, 44, $sshfp, 0, 0, 0, $ttl, $loc); 552 569 } else { 553 570 push @deferred, $rec unless $nodefer;
Note:
See TracChangeset
for help on using the changeset viewer.