[Pdns-dev]
patch to enable DENIC style auto generated serial numbers
Markus Warg
m.warg at kon.de
Mon Feb 6 16:27:07 CET 2006
Hi,
for all of you who might be in need of automatically generated DENIC
style (I name it DENIC style because DENIC is AFAIK the only registry
which looks into the serial and sends warnings or even errors in case
the serial is not well formed) serial numbers in power dns, the attached
(mini) patch might be useful. Have a look at the restrictions, though...
A DENIC style serial number consists of a 10 digit decimal that looks
like this: YYYYMMDDCC.
The patch applies to the generic sql (gmysql) backend only at the
moment, but it should work with any other SQL backend, too. The power
dns man page already tells the user to create database tables with a
field called change_date, you just need to add this field to your
queries (in fact, only one query is needed):
gmysql-list-query=select content,ttl,prio,type,domain_id,\
name,change_date from records where domain_id='%d'
What the patch does is: get the already existing change_date field from
the database, evaluate the most current change_date and create a serial
number from that date (was already builtin). This is done by using the
date for the first 8 digits. The last 2 digits are calculated by using
the following formula: (hour*60+minute)/15.
Restriction: This leaves you with 96 time slots per day. Means that if
you alter a record, do an AXFR or "host -t soa", alter another record
within 15 minutes, you will NOT get a new serial for the 2nd change.
We are currently using a replicated master scenario. Both pdns instances
answer non recursively.
To the developers: if you think that this patch is of use to the public,
please feel free to add it to the source tree.
A more flexible solution would be to cache the last serial +
change_date. With those two parameters, you can generate a new serial
whenever the SOA is queried. With more overhead on pdns side, of course.
regards,
Markus
-------------- next part --------------
244,245c244,246
< if(i.last_modified>newest)
< newest=i.last_modified;
---
> if(i.last_modified>newest) {
> newest=i.last_modified;
> }
246a248,251
>
> struct tm *ntr = localtime(&newest);
> newest = ((((1900 + ntr->tm_year) * 100) + (ntr->tm_mon + 1)) * 100 + ntr->tm_mday) * 100;
> newest += (ntr->tm_hour * 60 + ntr->tm_min + 1) / 15;
-------------- next part --------------
375a376,378
> if (row.size() > 6 && row[6] != "" && row[6].c_str() != NULL) {
> r.last_modified = atoi(row[6].c_str());
> }
More information about the Pdns-dev
mailing list