Search code examples
luapowerdns

PowerDNS - DNSQuestion is always nil


I have setup a PowerDNS (4.0.4-1+deb9u4) upon Debian 9 with a MySQL backend successfully and the system was resolving hosts correctly. I am attempting to add scripting to the recursor and have used the examples, Lua script examples. I have pointed the pdns-resolver's conf correctly at my lua script, and I see my log statements print correctly, but I am consistently receiving an error regarding the DNSQuestion instance being empty for all of the example lua functions.

For example:

function preresolve(dq)
    pdnslog("Got question for "..dq.qname:toString().." from "..dq.remoteaddr:toString().." to "..dq.localaddr:toString())
    return true;
end

Results in : STL error (a.root-servers.net/A from 127.0.0.1): Trying to cast a lua variable from "nil" to "b" (meaning the DNSQuestion instance is null).

Clearly the lua script is running, but for some reason, all the dq instances are empty.

Is there anything that I may have misunderstood or am missing that would cause the parameter to be nil?


Solution

  • Have your function return true or false so it will not return nil by default.