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