ffi.metatype( kr_query_t, {
__index = {
name = function(qry) return ffi.string(qry.sname, knot.knot_dname_size(qry.sname)) end,
- nslist = function(qry, list)
- assert(#list <= 4, 'maximum of 4 addresses can be evaluated for each query')
- for i, ns in ipairs(list) do
- assert(C.kr_nsrep_set(qry, i - 1, ns) == 0);
- end
- -- If less than maximum NSs, insert guard to terminate the list
- if #list < 4 then
- assert(C.kr_nsrep_set(qry, #list, nil) == 0);
- end
- end,
},
})
-- Metatype for request
end
end
+-- Override the list of nameservers (forwarders)
+local function set_nslist(qry, list)
+ for i, ns in ipairs(list) do
+ assert(ffi.C.kr_nsrep_set(qry, i - 1, ns) == 0);
+ end
+ -- If less than maximum NSs, insert guard to terminate the list
+ if #list < 4 then
+ assert(ffi.C.kr_nsrep_set(qry, #list, nil) == 0);
+ end
+end
+
-- Forward request, and solve as stub query
local function stub(target)
local list = {}
-- Switch mode to stub resolver, do not track origin zone cut since it's not real authority NS
qry.flags.STUB = true
qry.flags.ALWAYS_CUT = false
- qry:nslist(list)
+ set_nslist(qry, list)
return state
end
end
qry.flags.ALWAYS_CUT = false
qry.flags.NO_MINIMIZE = true
qry.flags.AWAIT_CUT = true
- qry:nslist(list)
+ set_nslist(qry, list)
return state
end
end