From 8e90439f9c788f5110c4d6fb366e0b64a1d6d3e8 Mon Sep 17 00:00:00 2001
From: Daniel Salzman <daniel.salzman@nic.cz>
Date: Wed, 21 Sep 2016 09:35:03 +0200
Subject: [PATCH] dnstap: code unification

---
 doc/man/knot.conf.5in     | 12 ++++++++++++
 doc/reference.rst         |  4 ++++
 src/knot/modules/dnstap.c | 18 +++++++++---------
 3 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/doc/man/knot.conf.5in b/doc/man/knot.conf.5in
index 678831663c..ac940dcc0d 100644
--- a/doc/man/knot.conf.5in
+++ b/doc/man/knot.conf.5in
@@ -1028,6 +1028,8 @@ mod\-dnstap:
     sink: STR
     identity: STR
     version: STR
+    log\-queries: BOOL
+    log\-responses: BOOL
 .ft P
 .fi
 .UNINDENT
@@ -1051,6 +1053,16 @@ A DNS server identity. Set empty value to disable.
 A DNS server version. Set empty value to disable.
 .sp
 \fIDefault:\fP server version
+.SS log\-queries
+.sp
+If enabled, query messages will be logged.
+.sp
+\fIDefault:\fP on
+.SS log\-responses
+.sp
+If enabled, response messages will be logged.
+.sp
+\fIDefault:\fP on
 .SH MODULE SYNTH-RECORD
 .sp
 This module is able to synthesize either forward or reverse records for the
diff --git a/doc/reference.rst b/doc/reference.rst
index 8918e9555f..479b60636e 100644
--- a/doc/reference.rst
+++ b/doc/reference.rst
@@ -1250,6 +1250,8 @@ A DNS server version. Set empty value to disable.
 
 *Default:* server version
 
+.. _mod-dnstap_log-queries:
+
 log-queries
 -----------
 
@@ -1257,6 +1259,8 @@ If enabled, query messages will be logged.
 
 *Default:* on
 
+.. _mod-dnstap_log-responses:
+
 log-responses
 -------------
 
diff --git a/src/knot/modules/dnstap.c b/src/knot/modules/dnstap.c
index b8af0c884a..057e38e409 100644
--- a/src/knot/modules/dnstap.c
+++ b/src/knot/modules/dnstap.c
@@ -34,13 +34,13 @@
 #define MOD_RESPONSES	"\x0D""log-responses"
 
 const yp_item_t scheme_mod_dnstap[] = {
-	{ C_ID,         YP_TSTR, YP_VNONE },
-	{ MOD_SINK,     YP_TSTR, YP_VNONE },
-	{ MOD_IDENTITY, YP_TSTR, YP_VNONE },
-	{ MOD_VERSION,  YP_TSTR, YP_VSTR = { "Knot DNS " PACKAGE_VERSION } },
-	{ MOD_QUERIES,	YP_TBOOL, YP_VBOOL = true },
-	{ MOD_RESPONSES,YP_TBOOL, YP_VBOOL = true },
-	{ C_COMMENT,    YP_TSTR, YP_VNONE },
+	{ C_ID,          YP_TSTR,  YP_VNONE },
+	{ MOD_SINK,      YP_TSTR,  YP_VNONE },
+	{ MOD_IDENTITY,  YP_TSTR,  YP_VNONE },
+	{ MOD_VERSION,   YP_TSTR,  YP_VSTR = { "Knot DNS " PACKAGE_VERSION } },
+	{ MOD_QUERIES,   YP_TBOOL, YP_VBOOL = { true } },
+	{ MOD_RESPONSES, YP_TBOOL, YP_VBOOL = { true } },
+	{ C_COMMENT,     YP_TSTR,  YP_VNONE },
 	{ NULL }
 };
 
@@ -238,7 +238,7 @@ int dnstap_load(struct query_plan *plan, struct query_module *self,
 
 	conf_val_t val;
 
-	// Set identity.
+	/* Set identity. */
 	val = conf_mod_get(self->config, MOD_IDENTITY, self->id);
 	if (val.code == KNOT_EOK) {
 		ctx->identity = strdup(conf_str(&val));
@@ -247,7 +247,7 @@ int dnstap_load(struct query_plan *plan, struct query_module *self,
 	}
 	ctx->identity_len = (ctx->identity != NULL) ? strlen(ctx->identity) : 0;
 
-	// Set version.
+	/* Set version. */
 	val = conf_mod_get(self->config, MOD_VERSION, self->id);
 	ctx->version = strdup(conf_str(&val));
 	ctx->version_len = strlen(ctx->version);
-- 
GitLab