On 19/04/2024 00.21, boris.kotyrev@gmail.com wrote:
Trying to make Policy Based Routing routing.
Looking for HOWTO/snippents of two API features :

I can't see how it's related, but I don't really know anything about policy-based routing.

1) Tracking Cache TTL for some records and ability to make requests against cache.

There is a flag in the protocol that instructs to only return answers from cache (and other local sources), e.g. you can add +nord to (k)dig commands. However, by default such queries are refused, because of privacy implications of that cache-snooping ability, and we currently only allow to unblock this globally, based on who asks.

Stable docs: https://www.knot-resolver.cz/documentation/v5.7.2/modules-refuse_nord.html

2) Printing some text properties in request/response (kres) functions - like domain name, is cached (yes/no), TTL, etc.

As I understood docs regarding Lua/C bindings is not finished yes.
But I'm not a experienced developer so reading .c files is not an option for me ;-)

It's possible to do a lot in Lua, but finding out what to do and how is often not really easier than in C, in my opinion.  It's probably possible to craft this as config in Lua, to print the information somewhere, but off the top of my head I don't see how exactly.

Maybe it will be better for you to use dnstap format to get the information out of Knot Resolver and then work with some other tools that consume dnstap.  Maybe you can even find some tool that already provides what you need.  Stable docs: https://www.knot-resolver.cz/documentation/v5.7.2/modules-dnstap.html

--Vladimir