Commit ad760e9e authored by Vladimír Čunát's avatar Vladimír Čunát

lua: remove some compatibility code

parent 36dca31b
......@@ -3,11 +3,10 @@ Knot Resolver 1.4.0 (2017-0x-yy)
Incompatible changes
--------------------
- lua: query flag-sets are no longer represented as plain integers.
Using bit operations directly on kres.query.* no longer works,
but other use cases should work as before. Still, it is recommended
to instead write code like qry.flags.NO_0X20 = true.
kres.query.* no longer works, and kr_query_t lost trivial methods
'hasflag' and 'resolved'.
You can instead write code like qry.flags.NO_0X20 = true.
Knot Resolver 1.3.2 (2017-07-28)
......
......@@ -252,16 +252,8 @@ 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,
-- legacy functions
hasflag = function(qry, flag) -- Note: `flag` is now a string - flag name.
return qry.flags[flag]
end,
resolved = function(qry)
return qry.flags.RESOLVED
end,
final = function(qry)
return qry:resolved() and (qry.parent == nil)
return qry.flags.RESOLVED and (qry.parent == nil)
end,
nslist = function(qry, list)
assert(#list <= 4, 'maximum of 4 addresses can be evaluated for each query')
......@@ -350,8 +342,7 @@ kres = {
-- Create a struct kr_qflags from a single flag name or a list of names.
mk_qflags = function (names)
local kr_qflags = ffi.typeof('struct kr_qflags')
-- compat. hacks
if names == 0 or names == nil then
if names == 0 or names == nil then -- compatibility: nil is common in lua
names = {}
elseif type(names) == 'string' then
names = {names}
......@@ -365,9 +356,6 @@ kres = {
end
return fs
end,
-- Don't use anymore - compat. hack: :hasflag() etc. now accept string names
-- but bit operations won't work.
query = setmetatable({}, { __index = function (t, name) return name end }),
CONSUME = 1, PRODUCE = 2, DONE = 4, FAIL = 8, YIELD = 16,
-- Metatypes. Beware that any pointer will be cast silently...
......
......@@ -17,7 +17,7 @@ mod.layer = {
req = kres.request_t(req)
qry = req:current()
-- Observe only authoritative answers
if mod.proxy == nil or not qry:resolved() then
if mod.proxy == nil or not qry.flags.RESOLVED then
return state
end
-- Synthetic AAAA from marked A responses
......
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