]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
modules/policy: optimize postrules
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 31 Jul 2019 13:55:43 +0000 (15:55 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 28 Nov 2019 12:05:30 +0000 (13:05 +0100)
I've never seen anyone use postrules.

modules/policy/policy.lua

index cf6a0b73859f8c45f9888a39aae50f8acd7727de..d78e0f0ac0fb629d6152c7214fcb33c32960cea9 100644 (file)
@@ -591,6 +591,8 @@ policy.layer = {
                       state
        end,
        finish = function(state, req)
+               -- Optimization for the typical case
+               if #policy.postrules == 0 then return state end
                -- Don't act on "resolved" cases.
                if bit.band(state, bit.bor(kres.FAIL, kres.DONE)) ~= 0 then return state end
                return policy.evaluate(policy.postrules, req, req:current(), state) or state