_config_template = """
function answerBasedOnLocalAddress(dq)
- local dest = dq.localaddr:toString()
+ local dest = tostring(dq.localaddr)
local i, j = string.find(dest, "[0-9.]+")
local addr = string.sub(dest, i, j)
local dashAddr = string.gsub(addr, "[.]", "-")
return false
end
- if dq.qname:toString() ~= 'lua-rule.advanced.tests.powerdns.com.' then
+ if tostring(dq.qname) ~= 'lua-rule.advanced.tests.powerdns.com.' then
print('invalid qname')
return false
end
function maintenance()
toBlock = exceedQRate(%d, %d)
for addr, count in pairs(toBlock) do
- if addr:toString() == "127.0.0.1" then
+ if tostring(addr) == "127.0.0.1" then
allowlisted = true
toBlock[addr] = nil
end
_ednsTestFunction = """
function testEDNSOptions(dq)
local options = dq:getEDNSOptions()
- local qname = dq.qname:toString()
+ local qname = tostring(dq.qname)
if string.match(qname, 'noedns') then
if next(options) ~= nil then
function alterProtobufResponse(dq, protobuf)
if luasmn:check(dq.qname) then
- requestor = newCA(dq.remoteaddr:toString()) -- called by testLuaProtobuf()
+ requestor = newCA(tostring(dq.remoteaddr)) -- called by testLuaProtobuf()
if requestor:isIPv4() then
requestor:truncate(24)
else
function alterProtobufQuery(dq, protobuf)
if luasmn:check(dq.qname) then
- requestor = newCA(dq.remoteaddr:toString()) -- called by testLuaProtobuf()
+ requestor = newCA(tostring(dq.remoteaddr)) -- called by testLuaProtobuf()
if requestor:isIPv4() then
requestor:truncate(24)
else
protobuf:setResponseCode(DNSRCode.NXDOMAIN) -- set protobuf response code to be NXDOMAIN
- local strReqName = dq.qname:toString() -- get request dns name
+ local strReqName = tostring(dq.qname) -- get request dns name
protobuf:setProtobufResponseType() -- set protobuf to look like a response and not a query, with 0 default time