Commit 412b097f authored by Marek Vavruša's avatar Marek Vavruša

daemon/lua: qry:resolved() and qry:final()

resolved() returns true if current query is resolved (i.e. authoritative)
final() returns true if current query is resolved and is not a subrequest (has no parent)
parent 5c14ca9d
......@@ -339,6 +339,12 @@ ffi.metatype( kr_query_t, {
assert(qry)
return C.kr_rplan_next(qry)
end,
resolved = function(qry)
return band(qry.flags, kres.query.RESOLVED) ~= 0
end,
final = function(qry)
return qry:resolved() and (qry.parent == nil)
end,
},
})
-- Metatype for request
......
......@@ -16,7 +16,7 @@ mod.layer = {
req = kres.request_t(req)
qry = req:current()
-- Observe only authoritative answers
if mod.proxy == nil or bit.band(qry.flags, kres.query.RESOLVED) == 0 then
if mod.proxy == nil or not qry:resolved() then
return state
end
-- Synthetic AAAA from marked A responses
......@@ -36,7 +36,7 @@ mod.layer = {
end
-- Observe AAAA NODATA responses
local is_nodata = (pkt:rcode() == kres.rcode.NOERROR) and (#answer == 0)
if pkt:qtype() == kres.type.AAAA and is_nodata and pkt:qname() == qry:name() then
if pkt:qtype() == kres.type.AAAA and is_nodata and pkt:qname() == qry:name() and qry:final() then
local next = req:push(pkt:qname(), kres.type.A, kres.class.IN, 0, qry)
next.flags = bit.band(qry.flags, kres.query.DNSSEC_WANT) + kres.query.AWAIT_CUT + MARK_DNS64
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment