]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
modules/renumber: fix renumber.name behaviour
authorOto Šťáva <oto.stava@nic.cz>
Mon, 8 Aug 2022 11:36:22 +0000 (13:36 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 8 Aug 2022 14:35:40 +0000 (16:35 +0200)
Fixes #760.

Also removes a warning in policy.REROUTE that is no longer true.

NEWS
modules/policy/policy.lua
modules/renumber/renumber.lua

diff --git a/NEWS b/NEWS
index d4f6369d1a4a143ff6968531eb0a79e0f9d5675d..c963d074db606887750f8d755c8fd14d4ea94e98 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ Bugfixes
 - daemon/http: improved URI checks to fix some proxies (#746, !1311)
 - daemon/tls: fixed a double-free for some cases of policy.TLS_FORWARD (!1314)
 - hints module: improve parsing comments in hosts files (!1315)
+- renumber module: renumbering works with name matching again (#760, !1334)
 
 
 Knot Resolver 5.5.1 (2022-06-14)
index 55a8de3cf13d1592b9f3c2bfe905ea9bb63f357f..4eba7494e4ed5d3d98ed127fbd643f1cd9b942c2 100644 (file)
@@ -199,11 +199,6 @@ function policy.REROUTE(tbl, names)
        local prefixes = {}
        for from, to in pairs(tbl) do
                local prefix = names and ren.name(from, to) or ren.prefix(from, to)
-               local bitlen = prefix[2]
-               if bitlen ~= nil and bitlen % 8 ~= 0 then
-                       log_warn(ffi.C.LOG_GRP_POLICY,
-                               'REROUTE: network mask - only /8, /16, /24 etc. are supported (entire octets are rewritten)')
-               end
                table.insert(prefixes, prefix)
        end
        -- Return rule closure
index 2e209c165a102a1fa971b951a6e8663fbed04aff..60803d54ab698a982fc89d49e7f36100c5a0795c 100644 (file)
@@ -25,10 +25,14 @@ local function mergeIps(ipNet, ipHost, intMask)
        local octetMask
        local result = ""
 
-       if (#ipNet ~= #ipHost) then
+       if #ipNet ~= #ipHost then
                return nil
        end
 
+       if intMask == nil then
+               return ipNet
+       end
+
        for currentOctetNo = 1, #ipNet do
                if intMask >= 8 then
                        result = result .. ipNet:sub(currentOctetNo,currentOctetNo)