Skip to content
Snippets Groups Projects
Verified Commit 699abe02 authored by Petr Špaček's avatar Petr Špaček
Browse files

policy.DEBUG: add also policy.REQTRACE for printing incoming packets

parent 7c4aa34e
Branches
Tags
1 merge request!957per-request verbose logging and debug log improvements
......@@ -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.
......
......@@ -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`.
......
......@@ -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
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment