diff --git a/doc/reference.rst b/doc/reference.rst index da3483525c48dce315bf5cd1ea14e5542cc341b0..8918e9555f347bd6d567758643d38eab3fd3c461 100644 --- a/doc/reference.rst +++ b/doc/reference.rst @@ -1212,6 +1212,8 @@ zone-specific logging, use this module in the proper zone configuration. sink: STR identity: STR version: STR + log-queries: BOOL + log-responses: BOOL .. _mod-dnstap_id: @@ -1248,6 +1250,20 @@ A DNS server version. Set empty value to disable. *Default:* server version +log-queries +----------- + +If enabled, query messages will be logged. + +*Default:* on + +log-responses +------------- + +If enabled, response messages will be logged. + +*Default:* on + .. _Module synth-record: Module synth-record diff --git a/src/knot/modules/dnstap.c b/src/knot/modules/dnstap.c index b60c1ca387db820c13a09d50742a7bf5b53d0238..b8af0c884a2315e634b692d522def5b7065db365 100644 --- a/src/knot/modules/dnstap.c +++ b/src/knot/modules/dnstap.c @@ -30,12 +30,16 @@ #define MOD_SINK "\x04""sink" #define MOD_IDENTITY "\x08""identity" #define MOD_VERSION "\x07""version" +#define MOD_QUERIES "\x0B""log-queries" +#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 }, { NULL } }; @@ -251,6 +255,14 @@ int dnstap_load(struct query_plan *plan, struct query_module *self, val = conf_mod_get(self->config, MOD_SINK, self->id); const char *sink = conf_str(&val); + /* Set log_queries. */ + val = conf_mod_get(self->config, MOD_QUERIES, self->id); + const bool log_queries = conf_bool(&val); + + /* Set log_responses. */ + val = conf_mod_get(self->config, MOD_RESPONSES, self->id); + const bool log_responses = conf_bool(&val); + /* Initialize the writer and the options. */ struct fstrm_writer *writer = dnstap_writer(sink); if (writer == NULL) { @@ -279,8 +291,12 @@ int dnstap_load(struct query_plan *plan, struct query_module *self, self->ctx = ctx; /* Hook to the query plan. */ - query_plan_step(plan, QPLAN_BEGIN, dnstap_message_log_query, self->ctx); - query_plan_step(plan, QPLAN_END, dnstap_message_log_response, self->ctx); + if (log_queries) { + query_plan_step(plan, QPLAN_BEGIN, dnstap_message_log_query, self->ctx); + } + if (log_responses) { + query_plan_step(plan, QPLAN_END, dnstap_message_log_response, self->ctx); + } return KNOT_EOK; fail: