# Vagrant
.vagrant
+
+# eclipse
+/.project
+/.cproject
+/.settings/
\ No newline at end of file
+Knot DNS 2.7.0 (2018-xx-xx)
+===========================
+
+Features:
+---------
+ - New zone serial policy DATESERIAL: yyyyMMDDvv (Thanks to Wolfgang Jung)
+
+
Knot DNS 2.6.0 (2017-09-29)
===========================
dnssec\-signing: BOOL
dnssec\-policy: STR
request\-edns\-option: INT:[HEXSTR]
- serial\-policy: increment | unixtime
+ serial\-policy: increment | unixtime | dateserial
min\-refresh\-interval: TIME
max\-refresh\-interval: TIME
module: STR/STR ...
\fBincrement\fP – The serial is incremented according to serial number arithmetic
.IP \(bu 2
\fBunixtime\fP – The serial is set to the current unix time
+.IP \(bu 2
+.INDENT 2.0
+.TP
+\fBdateserial\fP – The 10\-digit serial (YYYYMMDDnn) is incremented, the first
+8 digits match the current iso\-date
+.UNINDENT
.UNINDENT
.sp
\fBNOTE:\fP
with the transition to unix time. It may happen that the new serial will
be \(aqlower\(aq than the old one. If this is the case, the transition should be
done by hand (\fI\%RFC 1982\fP).
+.sp
+Use dateserial only if you expect less than 100 updates per day per zone.
.UNINDENT
.UNINDENT
.sp
dnssec-signing: BOOL
dnssec-policy: STR
request-edns-option: INT:[HEXSTR]
- serial-policy: increment | unixtime
+ serial-policy: increment | unixtime | dateserial
min-refresh-interval: TIME
max-refresh-interval: TIME
module: STR/STR ...
- ``increment`` – The serial is incremented according to serial number arithmetic
- ``unixtime`` – The serial is set to the current unix time
+- ``dateserial`` – The 10-digit serial (YYYYMMDDnn) is incremented, the first
+ 8 digits match the current iso-date
.. NOTE::
If your serial was in other than unix time format, be careful
be \'lower\' than the old one. If this is the case, the transition should be
done by hand (:rfc:`1982`).
+ Use dateserial only if you expect less than 100 updates per day per zone.
+
*Default:* increment
.. _zone_min-refresh-interval:
};
static const knot_lookup_t serial_policies[] = {
- { SERIAL_POLICY_INCREMENT, "increment" },
- { SERIAL_POLICY_UNIXTIME, "unixtime" },
+ { SERIAL_POLICY_INCREMENT, "increment" },
+ { SERIAL_POLICY_UNIXTIME, "unixtime" },
+ { SERIAL_POLICY_DATESERIAL, "dateserial" },
{ 0, NULL }
};
};
enum {
- SERIAL_POLICY_INCREMENT = 1,
- SERIAL_POLICY_UNIXTIME = 2,
+ SERIAL_POLICY_INCREMENT = 1,
+ SERIAL_POLICY_UNIXTIME = 2,
+ SERIAL_POLICY_DATESERIAL = 3,
};
enum {
return diffbrief2result[diffbrief];
}
+static uint32_t serial_next_date(uint32_t current)
+{
+ uint32_t next = current + 1;
+
+ struct tm now;
+ time_t current_time = time(NULL);
+ struct tm *gmtime_result = gmtime_r(¤t_time, &now);
+ if (gmtime_result == NULL) {
+ return next;
+ }
+
+ uint32_t yyyyMMdd00 = (1900 + now.tm_year) * 1000000 +
+ ( 1 + now.tm_mon ) * 10000 +
+ ( now.tm_mday) * 100;
+
+ if (next < yyyyMMdd00) {
+ next = yyyyMMdd00;
+ }
+
+ return next;
+}
+
uint32_t serial_next(uint32_t current, int policy)
{
switch (policy) {
return current + 1;
case SERIAL_POLICY_UNIXTIME:
return time(NULL);
+ case SERIAL_POLICY_DATESERIAL:
+ return serial_next_date(current);
default:
assert(0);
return 0;
* \brief Get next serial for given serial update policy.
*
* \param current Current SOA serial.
- * \param policy SERIAL_POLICY_INCREMENT or SERIAL_POLICY_UNIXTIME.
+ * \param policy SERIAL_POLICY_INCREMENT, SERIAL_POLICY_UNIXTIME or
+ * SERIAL_POLICY_DATESERIAL.
*
* \return New serial.
*/
-/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <assert.h>
#include <tap/basic.h>
#include <stdlib.h>
+#include <time.h>
#include "knot/zone/serial.h"
+#include "knot/conf/schema.h"
+#include "contrib/strtonum.h"
enum serials {
S_LOWEST = 0, // lowest value
return s;
}
+static void check_dateserial(uint32_t current, uint32_t expected, const char *msg)
+{
+ uint32_t next = serial_next(current, SERIAL_POLICY_DATESERIAL);
+ ok(next == expected, "dateserial: %s", msg);
+}
+
+static void test_dateserial(void)
+{
+ time_t now = time(NULL);
+
+ struct tm *gm_ret = gmtime(&now);
+ assert(gm_ret);
+
+ char str[32];
+ int ret = strftime(str, sizeof(str), "%Y%m%d00", gm_ret);
+ assert(ret > 0);
+
+ uint32_t serial0;
+ ret = str_to_u32(str, &serial0);
+ assert(ret == KNOT_EOK);
+
+ check_dateserial(2000010100, serial0, "from old date");
+ check_dateserial(serial0, serial0 + 1, "today's first increment");
+ check_dateserial(serial0 + 98, serial0 + 99, "today's last increment");
+ check_dateserial(2100010100, 2100010101, "from future date");
+}
+
int main(int argc, char *argv[])
{
- plan(20);
+ plan_lazy();
/* Serial compare test. */
ok(serial_compare(S_LOWEST, S_BELOW_MIDDLE) == SERIAL_LOWER,
ok(serial_compare(s2, s1) == SERIAL_INCOMPARABLE,
"serial compare: random opposites (s2 < s1)");
+ test_dateserial();
+
return 0;
}