]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
view: fix destination-based matching
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 21 Feb 2023 14:35:14 +0000 (15:35 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 10 Mar 2023 09:54:40 +0000 (10:54 +0100)
Apparently it's never worked since its introduction.

.addr is non-nil exactly when .dst_addr is non-nil
(which hapens iff the query originated externally).
Now we have semantics which was probably intended by the original code
(982162956a from 2016) but that semantics is still problematic
if you need both kinds of matching in a single request from client.

This matching by destination has never made it to docs,
so let's just add this simple fixup for now, and later
we'll steer users to new policy configuration anyway.

modules/view/view.lua

index f5e186261d3fb4aa268566172543b4e046d38904..d704384d58b6cf721d89e6e74059a54fa76261ee 100644 (file)
@@ -69,8 +69,9 @@ local function evaluate(state, req)
                                if execute(state, req, match_cb) then return end
                        end
                end
+       end
        -- Finally try :addr by the destination.
-       elseif req.qsource.dst_addr ~= nil then
+       if req.qsource.dst_addr ~= nil then
                for i = 1, #view.dst do
                        local pair = view.dst[i]
                        if match_subnet(pair[1], pair[2], pair[3], req.qsource.dst_addr) then