]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
offline_ksk: human readable timestamps in ksr and skr
authorLibor Peltan <libor.peltan@nic.cz>
Mon, 17 Dec 2018 19:23:16 +0000 (20:23 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Tue, 18 Dec 2018 11:02:05 +0000 (12:02 +0100)
src/utils/keymgr/offline_ksk.c

index 2bc55c0783053bd051bd10541624683bcfc4e368..959776592bbfdac21b653eaeb6939f3f66286927 100644 (file)
@@ -180,6 +180,14 @@ static void print_generated_message(void)
        printf("generated at %s by Knot DNS %s\n", buf, VERSION);
 }
 
+static void print_header(const char *of_what, knot_time_t timestamp, const char *contents)
+{
+       char date[64] = { 0 };
+       (void)knot_time_print(TIME_PRINT_ISO8601, timestamp, date, sizeof(date));
+       printf(";; %s %s %"PRIu64" (%s) =========\n%s", of_what, KSR_SKR_VER,
+              timestamp, date, contents);
+}
+
 static int ksr_once(kdnssec_ctx_t *ctx, char **buf, size_t *buf_size, knot_time_t *next_ksr)
 {
        knot_rrset_t *dnskey = NULL;
@@ -190,8 +198,7 @@ static int ksr_once(kdnssec_ctx_t *ctx, char **buf, size_t *buf_size, knot_time_
        }
        ret = dump_rrset_to_buf(dnskey, buf, buf_size);
        if (ret >= 0) {
-               printf(";; KeySigningRequest %s %"PRIu64" ===========\n%s",
-                      KSR_SKR_VER, ctx->now, *buf);
+               print_header("KeySigningRequest", ctx->now, *buf);
                ret = KNOT_EOK;
        }
 
@@ -278,8 +285,7 @@ static int ksr_sign_dnskey(kdnssec_ctx_t *ctx, knot_rrset_t *zsk, knot_time_t no
        }
        ret = key_records_dump(&buf, &buf_size, &r, true);
        if (ret == KNOT_EOK) {
-               printf(";; SignedKeyResponse %s %"PRIu64" ===========\n%s",
-                      KSR_SKR_VER, ctx->now, buf);
+               print_header("SignedKeyResponse", ctx->now, buf);
                *next_sign = knot_get_next_zone_key_event(&keyset);
        }