]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
policy.DEBUG: add also policy.REQTRACE for printing incoming packets
authorPetr Špaček <petr.spacek@nic.cz>
Wed, 18 Mar 2020 13:03:13 +0000 (14:03 +0100)
committerPetr Špaček <petr.spacek@nic.cz>
Wed, 25 Mar 2020 13:15:51 +0000 (14:15 +0100)
doc/config-logging-monitoring.rst
modules/policy/README.rst
modules/policy/policy.lua

index 0fc256b0d29d1d143245b62857918d6d055e196f..7dcc46bf2805510557eda210578c2c16fc51425b 100644 (file)
@@ -14,7 +14,7 @@ so by default logs from Knot Resolver should contain only couple lines a day.
 For debugging purposes it is possible to enable very verbose logging using
 :func:`verbose` function.
 
-.. function:: verbose([true | false])
+.. py:function:: verbose([true | false])
 
    :param: ``true`` to enable, ``false`` to disable verbose logging.
    :return: boolean Current state of verbose logging.
index a988b71213397c913f1d4f75441e7ffef2163f30..a11aa7db6bed2332edd06878bf345bcd500a6775 100644 (file)
@@ -178,6 +178,10 @@ Following actions act on request and then processing continue until first non-ch
         -- requests for example.net. and its subdomains
         policy.add(policy.suffix(policy.QTRACE, policy.todnames({'example.net'})))
 
+.. py:attribute:: REQTRACE
+
+   Pretty-print DNS requests from clients into the verbose log. It's useful for debugging weird DNS clients. Verbose logging must be enabled using :func:`verbose` for this policy to be effective. It makes most sense together with :ref:`mod-view`.
+
 .. py:attribute:: DEBUG_ALWAYS
 
    Enable extra verbose logging for all requests, including cache hits. See caveats for :func:`policy.DEBUG_IF`.
index 2f8708d88fb24dcefcb4ec4aaf67d8b1d9c3f5a7..90770514c6d99f7016d38d461cb8cb6b96334a47 100644 (file)
@@ -542,10 +542,17 @@ local debug_logfinish_cb = ffi.cast('trace_callback_f', function (req)
                tostring(req.answer))
 end)
 
+-- log request packet
+function policy.REQTRACE(_, req)
+       ffi.C.kr_log_req(req, 0, 0, 'dbg', 'request packet:\n%s',
+               tostring(req.qsource.packet))
+end
+
 function policy.DEBUG_ALWAYS(_, req)
        policy.QTRACE(_, req)
        req.trace_log = debug_logline_cb
        req.trace_finish = debug_logfinish_cb
+       policy.REQTRACE(_, req)
        return
 end
 
@@ -567,6 +574,7 @@ function policy.DEBUG_IF(test)
                        req.trace_log:free()
                        req.trace_finish:free()
                end)
+               policy.REQTRACE(state, req)
                return
        end
 end