From: Vladimír Čunát Date: Tue, 1 Aug 2017 16:38:42 +0000 (+0200) Subject: lua: remove :nslist from kr_query_t X-Git-Tag: v1.4.0~20^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0bc5ea97fcb2070d04cc01c90bdc18c8c65dd5e;p=thirdparty%2Fknot-resolver.git lua: remove :nslist from kr_query_t It was rather low-level anyway. --- diff --git a/daemon/lua/kres.lua.in b/daemon/lua/kres.lua.in index dee3efe7f..ebf5ff259 100644 --- a/daemon/lua/kres.lua.in +++ b/daemon/lua/kres.lua.in @@ -252,16 +252,6 @@ local kr_query_t = ffi.typeof('struct kr_query') 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 diff --git a/modules/policy/policy.lua b/modules/policy/policy.lua index c9585ef6e..10aeb64b4 100644 --- a/modules/policy/policy.lua +++ b/modules/policy/policy.lua @@ -63,6 +63,17 @@ local function mirror(target) 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 = {} @@ -79,7 +90,7 @@ local function stub(target) -- 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 @@ -103,7 +114,7 @@ local function forward(target) 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