Changeset 481 for trunk/dns-rpc.cgi
- Timestamp:
- 03/14/13 15:33:42 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns-rpc.cgi
r480 r481 313 313 _commoncheck(\%args); 314 314 315 my $ret = DNSDB::getSOA($dbh,$args{defrec}, $args{revrec}, $args{id});315 my $ret = $dnsdb->getSOA($args{defrec}, $args{revrec}, $args{id}); 316 316 if (!$ret) { 317 317 if ($args{defrec} eq 'y') { … … 331 331 _commoncheck(\%args); 332 332 333 my $ret = DNSDB::getRecLine($dbh,$args{defrec}, $args{revrec}, $args{id});334 335 die $ DNSDB::errstr if !$ret;333 my $ret = $dnsdb->getRecLine($args{defrec}, $args{revrec}, $args{id}); 334 335 die $dnsdb->errstr if !$ret; 336 336 337 337 return $ret; … … 350 350 $args{direction} = 'ASC' if !$args{direction}; 351 351 352 my $ret = DNSDB::getDomRecs($dbh,(defrec => $args{defrec}, revrec => $args{revrec}, id => $args{id},352 my $ret = $dnsdb->getDomRecs(defrec => $args{defrec}, revrec => $args{revrec}, id => $args{id}, 353 353 offset => $args{offset}, sortby => $args{sortby}, sortorder => $args{sortorder}, 354 filter => $args{filter}) );355 356 die $ DNSDB::errstr if !$ret;354 filter => $args{filter}); 355 356 die $dnsdb->errstr if !$ret; 357 357 358 358 return $ret; … … 371 371 $args{direction} = 'ASC' if !$args{direction}; 372 372 373 my $ret = DNSDB::getRecCount($dbh,$args{defrec}, $args{revrec}, $args{id}, $args{filter});374 375 die $ DNSDB::errstr if !$ret;373 my $ret = $dnsdb->getRecCount($args{defrec}, $args{revrec}, $args{id}, $args{filter}); 374 375 die $dnsdb->errstr if !$ret; 376 376 377 377 return $ret; … … 386 386 _ttlcheck(\%args); 387 387 388 my @recargs = ($ dbh, $args{defrec}, $args{revrec}, $args{parent_id},388 my @recargs = ($args{defrec}, $args{revrec}, $args{parent_id}, 389 389 \$args{name}, \$args{type}, \$args{address}, $args{ttl}, $args{location}); 390 390 if ($args{type} == $DNSDB::reverse_typemap{MX} or $args{type} == $DNSDB::reverse_typemap{SRV}) { … … 396 396 } 397 397 398 my ($code, $msg) = DNSDB::addRec(@recargs);398 my ($code, $msg) = $dnsdb->addRec(@recargs); 399 399 400 400 die $msg if $code eq 'FAIL'; … … 409 409 # get old line, so we can update only the bits that the caller passed to change 410 410 # note we subbed address for val since it's a little more caller-friendly 411 my $oldrec = DNSDB::getRecLine($dbh,$args{defrec}, $args{revrec}, $args{id});411 my $oldrec = $dnsdb->getRecLine($args{defrec}, $args{revrec}, $args{id}); 412 412 foreach my $field (qw(name type address ttl location distance weight port)) { 413 413 $args{$field} = $oldrec->{$field} if !$args{$field} && defined($oldrec->{$field}); … … 416 416 # note dist, weight, port are not required on all types; will be ignored if not needed. 417 417 # parent_id is the "primary" zone we're updating; necessary for forward/reverse voodoo 418 my ($code, $msg) = DNSDB::updateRec($dbh,$args{defrec}, $args{revrec}, $args{id}, $args{parent_id},418 my ($code, $msg) = $dnsdb->updateRec($args{defrec}, $args{revrec}, $args{id}, $args{parent_id}, 419 419 \$args{name}, \$args{type}, \$args{address}, $args{ttl}, $args{location}, 420 420 $args{distance}, $args{weight}, $args{port}); … … 440 440 # We need to strip the CIDR mask on IPv4 /32 assignments, or we just add a new record all the time. 441 441 my $filt = ($cidr->{isv6} || $cidr->masklen != 32 ? "$cidr" : $cidr->addr); 442 my $reclist = DNSDB::getDomRecs($dbh,defrec => 'n', revrec => 'y',442 my $reclist = $dnsdb->getDomRecs(defrec => 'n', revrec => 'y', 443 443 id => $zonelist->[0]->{rdns_id}, filter => $filt); 444 444 if (scalar(@$reclist) == 0) { … … 454 454 || $rec->{type} == 65282 || $rec->{type} == 65283 || $rec->{type} == 65284; 455 455 next unless $rec->{val} eq $filt; # make sure we really update the record we want to update. 456 updateRec(defrec =>'n', revrec => 'y', id => $rec->{record_id},456 $dnsdb->updateRec(defrec =>'n', revrec => 'y', id => $rec->{record_id}, 457 457 parent_id => $zonelist->[0]->{rdns_id}, %args); 458 458 $flag = 1; … … 463 463 # Aren't Magic Numbers Fun? See pseudotype list in dnsadmin. 464 464 my $type = ($cidr->{isv6} ? 65282 : ($cidr->masklen == 32 ? 65280 : 65283) ); 465 addRec(defrec =>'n', revrec => 'y', parent_id => $zonelist->[0]->{rdns_id}, type => $type,465 $dnsdb->addRec(defrec =>'n', revrec => 'y', parent_id => $zonelist->[0]->{rdns_id}, type => $type, 466 466 address => "$cidr", %args); 467 467 } … … 474 474 # that spans multiple reverse zones (eg, /23 CIDR -> 2 /24 rzones) 475 475 foreach my $zdata (@$zonelist) { 476 my $reclist = DNSDB::getDomRecs($dbh,defrec => 'n', revrec => 'y',476 my $reclist = $dnsdb->getDomRecs(defrec => 'n', revrec => 'y', 477 477 id => $zdata->{rdns_id}, filter => $zdata->{revnet}); 478 478 if (scalar(@$reclist) == 0) { 479 479 my $type = ($args{cidr}->{isv6} ? 65282 : ($args{cidr}->masklen == 32 ? 65280 : 65283) ); 480 addRec(defrec =>'n', revrec => 'y', parent_id => $zdata->{rdns_id}, type => $type,480 $dnsdb->addRec(defrec =>'n', revrec => 'y', parent_id => $zdata->{rdns_id}, type => $type, 481 481 address => "$args{cidr}", %args); 482 482 } else { … … 485 485 # types are nominally impossible here. 486 486 next unless $rec->{type} == 65282 || $rec->{type} == 65283 || $rec->{type} == 65284; 487 updateRec(defrec =>'n', revrec => 'y', id => $rec->{record_id},487 $dnsdb->updateRec(defrec =>'n', revrec => 'y', id => $rec->{record_id}, 488 488 parent_id => $zdata->{rdns_id}, %args); 489 489 last; # only do one record. … … 499 499 _commoncheck(\%args, 'y'); 500 500 501 my ($code, $msg) = DNSDB::delRec($dbh,$args{defrec}, $args{recrev}, $args{id});501 my ($code, $msg) = $dnsdb->delRec($args{defrec}, $args{recrev}, $args{id}); 502 502 503 503 die $msg if $code eq 'FAIL'; … … 524 524 if ($args{delsubs}) { 525 525 # Delete ALL EVARYTHING!!one11!! in $args{cidr} 526 my $reclist = DNSDB::getDomRecs($dbh,defrec => 'n', revrec => 'y', id => $zonelist->[0]->{rdns_id});526 my $reclist = $dnsdb->getDomRecs(defrec => 'n', revrec => 'y', id => $zonelist->[0]->{rdns_id}); 527 527 foreach my $rec (@$reclist) { 528 528 my $reccidr = new NetAddr::IP $rec->{val}; … … 534 534 $rec->{type} == 12 || $rec->{type} == 65282 || 535 535 $rec->{type} == 65283 || $rec->{type} == 65284) { 536 my ($code,$msg) = DNSDB::delRec($dbh,'n', 'y', $rec->{record_id});536 my ($code,$msg) = $dnsdb->delRec('n', 'y', $rec->{record_id}); 537 537 } else { 538 my $ret = DNSDB::downconvert($dbh,$rec->{record_id}, $DNSDB::reverse_typemap{A});538 my $ret = $dnsdb->downconvert($rec->{record_id}, $DNSDB::reverse_typemap{A}); 539 539 } 540 540 } … … 542 542 # Edge case; we've just gone and axed all the records in the reverse zone. 543 543 # Re-add one to match the parent if we've been given a pattern to use. 544 addRec(defrec =>'n', revrec => 'y', parent_id => $zonelist->[0]->{rdns_id},544 $dnsdb->addRec(defrec =>'n', revrec => 'y', parent_id => $zonelist->[0]->{rdns_id}, 545 545 type => ($zone->{isv6} ? 65284 : 65283), address => "$cidr", %args); 546 546 } … … 551 551 # We need to strip the CIDR mask on IPv4 /32 assignments, or we can't find single-IP records 552 552 my $filt = ($cidr->{isv6} || $cidr->masklen != 32 ? "$cidr" : $cidr->addr); 553 my $reclist = DNSDB::getDomRecs($dbh,defrec => 'n', revrec => 'y',553 my $reclist = $dnsdb->getDomRecs(defrec => 'n', revrec => 'y', 554 554 id => $zonelist->[0]->{rdns_id}, filter => $filt, sortby => 'val', sortorder => 'DESC'); 555 555 foreach my $rec (@$reclist) { … … 559 559 $rec->{type} == 65282 || $rec->{type} == 65283 ||$rec->{type} == 65284; 560 560 if ($args{delforward} || $rec->{type} == 12) { 561 my ($code,$msg) = DNSDB::delRec($dbh,'n', 'y', $rec->{record_id});561 my ($code,$msg) = $dnsdb->delRec('n', 'y', $rec->{record_id}); 562 562 die $msg if $code eq 'FAIL'; 563 563 return $msg; 564 564 } else { 565 my $ret = DNSDB::downconvert($dbh,$rec->{record_id}, $DNSDB::reverse_typemap{A});566 die $ DNSDB::errstr if !$ret;565 my $ret = $dnsdb->downconvert($rec->{record_id}, $DNSDB::reverse_typemap{A}); 566 die $dnsdb->errstr if !$ret; 567 567 return "A+PTR for $args{cidr} split and PTR removed"; 568 568 } … … 579 579 # that spans multiple reverse zones (eg, /23 CIDR -> 2 /24 rzones) 580 580 foreach my $zdata (@$zonelist) { 581 my $reclist = DNSDB::getDomRecs($dbh,defrec => 'n', revrec => 'y', id => $zdata->{rdns_id});581 my $reclist = $dnsdb->getDomRecs(defrec => 'n', revrec => 'y', id => $zdata->{rdns_id}); 582 582 if (scalar(@$reclist) == 0) { 583 583 # nothing to do? or do we (re)add a record based on the parent? … … 595 595 $rec->{type} == 12 || $rec->{type} == 65282 || 596 596 $rec->{type} == 65283 || $rec->{type} == 65284) { 597 my ($code,$msg) = DNSDB::delRec($dbh,'n', 'y', $rec->{record_id});597 my ($code,$msg) = $dnsdb->delRec('n', 'y', $rec->{record_id}); 598 598 } else { 599 my $ret = DNSDB::downconvert($dbh,$rec->{record_id}, $DNSDB::reverse_typemap{A});599 my $ret = $dnsdb->downconvert($rec->{record_id}, $DNSDB::reverse_typemap{A}); 600 600 } 601 601 } # foreach @$reclist … … 604 604 # We've just gone and axed all the records in the reverse zone. 605 605 # Re-add one to match the parent if we've been given a pattern to use. 606 addRec(defrec =>'n', revrec => 'y', parent_id => $zdata->{rdns_id},606 $dnsdb->addRec(defrec =>'n', revrec => 'y', parent_id => $zdata->{rdns_id}, 607 607 type => ($cidr->{isv6} ? 65284 : 65283), 608 608 address => $zdata->{revnet}, name => $args{parpatt}, %args);
Note:
See TracChangeset
for help on using the changeset viewer.