2

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?

SmittySmee
  • 370
  • 2
  • 11

1 Answers1

1

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

Piglet
  • 27,501
  • 3
  • 20
  • 43
  • It’s not that the function is returning the wrong type, it’s that the function is receiving the incorrect type. – SmittySmee Nov 10 '19 at 14:14
  • @SmittySmee which function? if dq were nil you would face script errors for indexing nil values. all preresolve examples return values – Piglet Nov 10 '19 at 15:19
  • The function from the example. The parameter, dq, for preresolve function is nil. I have even added a condition check for nil and it meets that condition. Let me know if I am not making sense. – SmittySmee Nov 10 '19 at 19:34
  • @SmittySmee if dq is nil the error is not related to the provided code. – Piglet Nov 11 '19 at 07:10
  • For the `STL error (a.root-servers.net/A from 127.0.0.1): Trying to cast a lua variable from "nil" to "b"` this was due to the non-valid return type. I followed the instructions from building from source and added a few libraries and now am no longer receiving the nil either. I am marking this as the accepted answer as it removes the `STL` error. – SmittySmee Nov 22 '19 at 20:46