Update of /cvsroot/ispman/ispman/lib/ISPMan/DNSMan
In directory sc8-pr-cvs1:/tmp/cvs-serv27557/lib/ISPMan/DNSMan
Modified Files:
SOArecords.pm
Log Message:
This patch makes it possible to use DNS serials on the format
YYYYMMDDnn.
The behaviour is defined using a parameter in ispman.conf:
'DNSSerialFormat' = 'date' or 'timestamp';
(provied by Tarjei Huse)
Index: SOArecords.pm
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/ISPMan/DNSMan/SOArecords.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- SOArecords.pm 4 Jan 2004 18:56:15 -0000 1.16
+++ SOArecords.pm 14 Jan 2004 22:57:40 -0000 1.17
@@ -12,6 +12,7 @@
getSOA
touchSOA
setDNSsOARecord
+ updateSOASerial
);
$VERSION = '0.01';
@@ -42,11 +43,13 @@
sub modifyDNSsOARecords {
my $self=shift;
my $r=shift;
-
+ my $soa=$self->getSOA($r->param('ispmanDomain'));
+ $soa->{'serial'} = $self->updateSOASerial($soa->{'serial'});
+
$self->delTree($self->getsOARecordDn($r->param("ispmanDomain")));
$self->setDNSsOARecord($r->param("ispmanDomain"), $r->param('primary'),
$r->param('rootmail'),
- time(),
+ $soa->{'serial'},
$r->param('refresh'),
$r->param('retry'),
$r->param('expire'),
@@ -89,11 +92,13 @@
my $soa=$self->getSOA($domain);
+ $soa->{'serial'} = $self->updateSOASerial($soa->{'serial'});
+
$self->delTree($self->getsOARecordDn($domain));
$self->setDNSsOARecord($domain,
$soa->{'primary'},
$soa->{'rootmail'},
- time(),
+ $soa->{'serial'},
$soa->{'refresh'},
$soa->{'retry'},
$soa->{'expire'},
@@ -110,6 +115,38 @@
my $h=$self->getEntriesAsHashRef($dn, "&(objectclass=dnsZone)(nSRecord=*)", ["nSRecord", "relativeDomainName"]);
}
+# updateSOASerial - generates the correct serial for the record.
+# correct format: YYYYMMDDnn
+sub updateSOASerial {
+ my $self=shift;
+ my $serial=shift;
+
+ if ($self->{'Config'}->{'DNSSerialFormat'} eq 'timestamp') {
+ return time();
+ }
+
+ my @localtime = localtime();
+ my $year = $localtime[5] + 1900;
+ my $month = $localtime[4] + 1;
+ my $day = $localtime[3] ;
+
+ my $index = substr($serial,-2,2);
+ my $olddate = substr($serial,0,8);
+
+ $day = "0$day" if ($day < 10);
+ $month = "0$month" if ($month < 10);
+
+ my $newdate = $year.$month.$day;
+
+ if ($olddate ne $newdate) {
+ $serial = $newdate."01";
+ } elsif ($olddate == $newdate) {
+ $index++;
+ $serial = $olddate . $index;
+ }
+
+ return $serial;
+}
1;
__END__
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.