Changeset 795
- Timestamp:
- 11/03/20 13:13:33 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r792 r795 505 505 my %args = @_; 506 506 507 ##fixme: add alternate serial schemes here 507 ##fixme: refine to adjust for serial wraparound, ie, if switching from ISO to Unix, 508 # the serial effectively runs backwards. technically this breaks AXFR slaves. 509 510 # heavy lifting done in this sub-sub. updates may be needed on a forward zone, reverse zone, or both, depending. 511 sub __doupdate { 512 my $rev = shift; 513 my $zid = shift; 514 my $tname = _zonetable('n', $rev); 515 my $pname = _recparent('n', $rev); 516 my ($sertype,$serial) = $dbh->selectrow_array("SELECT sertype,zserial FROM $tname WHERE $pname = ?", undef, $zid) or die $dbh->errstr; 517 if ($sertype eq 'U') { 518 # Unix timestamp 519 $dbh->do("UPDATE $tname SET changed = 'y',zserial = ? WHERE $pname = ?", undef, (scalar(time), $zid) ); 520 } elsif ($sertype eq 'D') { 521 # ISO datestamp (YYYYMMDDnn) 522 my $newserial = strftime("%Y%m%d00", localtime); 523 if ($newserial > $serial) { 524 # new day, use the new serial 525 $serial = $newserial; 526 } else { 527 # change on same day, increment existing serial 528 $serial++; 529 ##fixme: do we need to check for overflow? (eg 2020091599 -> 2020091600 despite not being 2020-09-16) 530 # technically yes, practically no (effectively falls back to a variation of the simple sequential update) 531 # - might be a local policy violation. also, any such zone is probably better served by a fixed stub 532 # and DDNS as supported by BIND etc 533 } 534 $dbh->do("UPDATE $tname SET changed = 'y',zserial = ? WHERE $pname = ?", undef, ($serial, $zid) ); 535 } elsif ($sertype eq 'S') { 536 # Simple sequential number 537 $dbh->do("UPDATE $tname SET changed = 'y', zserial = zserial + 1 WHERE $pname = ?", undef, $zid ); 538 } else { 539 ##fixme: just fall back to simple sequential? shouldn't be possible to have any value other than U, D, or S 540 # Your llama is on fire 541 } 542 } 508 543 509 544 if ($args{rdns_id}) { 510 $dbh->do("UPDATE revzones SET changed = 'y',zserial = ? WHERE rdns_id = ?", undef, (scalar(time), $args{rdns_id}) ); 511 } 545 __doupdate('y', $args{rdns_id}); 546 } 547 512 548 if ($args{domain_id}) { 513 $dbh->do("UPDATE domains SET changed = 'y',zserial = ? WHERE domain_id = ?", undef, (scalar(time), $args{domain_id}) ); 514 } 549 __doupdate('n', $args{domain_id}); 550 } 551 515 552 } # end _updateserial() 516 553
Note:
See TracChangeset
for help on using the changeset viewer.