Changeset 270
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r269 r270 1319 1319 my $zone = NetAddr::IP->new(shift); 1320 1320 return ('FAIL',"Zone name must be a valid CIDR netblock") unless ($zone && $zone->addr !~ /^0/); 1321 my $revpatt = shift; 1321 my $revpatt = shift; # construct a custom (A/AAAA+)? PTR template record 1322 1322 my $group = shift; 1323 1323 my $state = shift; … … 1344 1344 1345 1345 my $warnstr = ''; 1346 my $defttl = 3600; # 1 hour should be reasonable. And unless things have gone horribly 1347 # wrong, we should have a value to override this anyway. 1346 1348 1347 1349 # Wrap all the SQL in a transaction … … 1375 1377 # While we're at it, we substitute $zone for ZONE in the value. 1376 1378 if ($val eq 'ZONE') { 1379 next if $revpatt; # If we've got a pattern, we skip the default record version. 1377 1380 ##fixme? do we care if we have multiple whole-zone templates? 1378 1381 $val = $zone->network; … … 1419 1422 "[new $zone] Added SOA record [contact $tmp1[0]] [master $tmp1[1]] ". 1420 1423 "[refresh $tmp2[0]] [retry $tmp2[1]] [expire $tmp2[2]] [minttl $tmp2[3]], TTL $ttl")); 1424 $defttl = $tmp2[3]; 1421 1425 } else { 1422 1426 my $logentry = "[new $zone] Added record '$host $typemap{$type}"; … … 1427 1431 } 1428 1432 1429 # Generate record based on provided pattern. 1430 my $addr; 1431 if (_ipparent($dbh, 'n', 'y', \$tmpval, $rdns_id, \$addr)) { 1432 $val = $addr->addr; 1433 } else { 1434 $warnstr .= "\nDefault record '$val $typemap{$type} $host' doesn't fit in $zone, skipping"; 1435 next; 1436 } 1433 # Generate record based on provided pattern. 1434 if ($revpatt) { 1435 my $host; 1436 my $type = ($zone->{isv6} ? 65284 : 65283); 1437 my $val = $zone->network; 1438 1439 # Substitute $zone for ZONE in the hostname. 1440 $host = _ZONE($zone, $revpatt); 1441 1442 my $domid = 0; 1443 if (!($domid = _hostparent($dbh, $host))) { 1444 $warnstr .= "\nDefault pattern added as PTR template instead of $typemap{$type}; domain not found for $host"; 1445 $type = 65282; 1446 $domid = 0; # just to be explicit. 1447 } 1448 1449 $sth_in->execute($domid,$host,$type,$val,$defttl); 1450 } 1437 1451 1438 1452 # If there are warnings (presumably about default records skipped for cause) log them -
trunk/dns.cgi
r269 r270 448 448 # getRecByName($dbh, (revrec => $webvar{revrec}, defrec => $webvar{defrec}, host => 'string')); 449 449 450 if ($webvar{add_failed}) { 451 $page->param(add_failed => 1); 452 $page->param(errmsg => $webvar{errmsg}); 450 if ($session->param('add_failed')) { 451 $session->clear('add_failed'); 452 $page->param(errmsg => $session->param('errmsg')); 453 $session->clear('errmsg'); 453 454 $page->param(revzone => $webvar{revzone}); 454 455 $page->param(revpatt => $webvar{revpatt}); … … 475 476 } else { 476 477 logaction(0, $session->param("username"), $webvar{group}, "Failed adding reverse zone $webvar{revzone} ($msg)"); 477 changepage(page => "newrevzone", revrec => 'y', add_failed => 1, revzone => $webvar{revzone},478 478 $session->param('add_failed', 1); 479 changepage(page => "newrevzone", revzone => $webvar{revzone}, revpatt => $webvar{revpatt}, errmsg => $msg); 479 480 } 480 481 -
trunk/templates/newrevzone.tmpl
r260 r270 15 15 <tr><td> 16 16 <table border="0" cellspacing="2" cellpadding="2" width="100%"> 17 <TMPL_IF add_failed> <tr><td class="errhead" colspan="2">Error adding reverse zone <TMPL_VAR NAME=revzone>:17 <TMPL_IF errmsg> <tr><td class="errhead" colspan="2">Error adding reverse zone <TMPL_VAR NAME=revzone>: 18 18 <TMPL_VAR NAME=errmsg></td></tr></TMPL_IF> 19 19 <tr class="darkrowheader"><td colspan="2" align="center">Add Reverse Zone</td></tr>
Note:
See TracChangeset
for help on using the changeset viewer.