[dnsdist] LUA DNS Parser
Otto Moerbeek
otto at drijf.net
Fri Jun 20 08:54:56 UTC 2025
On Fri, Jun 20, 2025 at 12:43:04AM -0700, japantoday--- via dnsdist wrote:
> I was attempting to run this sample code I found on the website.
>
> function dumpPacket(dq)
> local packet = dq:getContent()
> local overlay = newDNSPacketOverlay(packet)
> print(overlay.qname)
> print(overlay.qtype)
> print(overlay.qclass)
> local count = overlay:getRecordsCountInSection(DNSSection.Answer)
> print(count)
> for idx=0, count-1 do
> local record = overlay:getRecord(idx)
> print(record.name)
> print(record.type)
> print(record.class)
> print(record.ttl)
> print(record.place)
> print(record.contentLength)
> print(record.contentOffset)
> end
> return DNSAction.None
> end
>
> addAction(AllRule(), LuaAction(dumpPacket))
>
>
>
>
> Essentially, it should print out details about the DNS answer it received.
>
> On my machine, I get nothing. It thinks count is always 0, when in fact
> that is not true. At this point I am trying to figure out why this code
> does not work.
Queries have no response data. Try
addResponseAction(AllRule(), LuaResponseAction(dumpPacket))
-Otto
More information about the dnsdist
mailing list