From: Vladimír Čunát Date: Mon, 30 Jan 2017 14:58:55 +0000 (+0100) Subject: policy: add policy.FLAGS, (un)setting query flags X-Git-Tag: v1.3.0~23^2~75^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a55913672bc50516e2481bc8feef47599f8ef1d;p=thirdparty%2Fknot-resolver.git policy: add policy.FLAGS, (un)setting query flags --- diff --git a/modules/policy/policy.lua b/modules/policy/policy.lua index d7d3f83e3..793ecd802 100644 --- a/modules/policy/policy.lua +++ b/modules/policy/policy.lua @@ -97,9 +97,20 @@ local function reroute(tbl, names) return ren.rule(prefixes) end +-- Set and clear some query flags (TODO: documentation). +local function flags(opts_set, opts_clear) + return function(state, req) + req = kres.request_t(req) + local qry = req:current() + qry.flags = bit.band(bit.bor(qry.flags, opts_set or 0), bit.bnot(opts_clear or 0)) + return nil -- chain rule + end +end + local policy = { -- Policies - PASS = 1, DENY = 2, DROP = 3, TC = 4, QTRACE = 5, FORWARD = forward, REROUTE = reroute, MIRROR = mirror, + PASS = 1, DENY = 2, DROP = 3, TC = 4, QTRACE = 5, + FORWARD = forward, REROUTE = reroute, MIRROR = mirror, FLAGS = flags, -- Special values ANY = 0, }