Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 62031
Status: resolved
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: BTIETZ [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: adding newserial() for Net::DNS::RR::SOA-objects
using the newserial-method is a easy way to create a new serial for a given SOA. This method is based on the equal named method from DNS::ZoneParse.
Subject: 0001--Net-DNS-RR-SOA-Adding-newserial.patch
From 1b0c4e87fa25e35ed76dc568feb4a12182fe0053 Mon Sep 17 00:00:00 2001 From: Benjamin Tietz <benjamin@micronet24.de> Date: Sun, 10 Oct 2010 20:02:33 +0200 Subject: [PATCH] [Net::DNS::RR::SOA] Adding newserial This function will update the serial of a given SOA-Record. --- lib/Net/DNS/RR/SOA.pm | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/lib/Net/DNS/RR/SOA.pm b/lib/Net/DNS/RR/SOA.pm index 80df297..9766dc5 100644 --- a/lib/Net/DNS/RR/SOA.pm +++ b/lib/Net/DNS/RR/SOA.pm @@ -77,6 +77,20 @@ sub rr_rdata { return $rdata; } +sub new_serial { + my ($self, $inc) = @_; + + if($inc) { + $self->serial += $inc; + } else { + my $newserial = strftime("%Y%m%d%H", localtime(time)); + $self->serial = ($newserial > $self->serial) + ? $newserial + : $self->serial + 1; + } + return $self->serial; +} + sub _normalize_dnames { my $self=shift; @@ -165,12 +179,23 @@ Returns the zone's expire interval. Returns the minimum (default) TTL for records in this zone. +=head2 newserial + + $rr->newserial(); + +Generates a new serial for this SOA depending on the current date and a +counter. When called without an argument the serial will have the form +YYYYMMDDxx, where xx starts at 00. If the current serial did have the same +date, xx will be incremented. + =head1 COPYRIGHT Copyright (c) 1997-2002 Michael Fuhr. Portions Copyright (c) 2002-2004 Chris Reinhardt. +Portions Copyright (c) 2010 Benjamin Tietz. + All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. -- 1.5.6.5
Hi Benjamin, The requested functionality is added, although not with your patch (without strftime which would add another dependency and with some perl-code fixes, you did not test your code, did you?). Also I changed the documentation you provided with one that is based more on DNS::ZoneParse::new_serial, because I think it more clearly describes wath new_serial does. Regards, Willem
Hi Benjamin, Dick Franks has contributed a very nice and more generic system for serial number management in which the serial number may be adjusted by just using the serial method and passing it an auxiliary SEQUENTIAL() function. Also an auxiliary function to generate a YYYYMMDDxx formatted number is provided. Furthermore it takes into account wrapping and serial number arithmetic as defined in RFC1982. I do not see the need for a new_serial number function, because the only real added functionality would be the ability to increment the serial number with a different number than one (which should never be necessary or only needed in very rare and specific cases in which a little bit extra code wouldn't harm). The function is thus dropped and replaced with Dick's superior serial management implementation. Best regards, Willem