]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
rebinding: deduplicate code of policy.REFUSE
authorVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 2 Apr 2020 07:46:50 +0000 (09:46 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 2 Apr 2020 12:35:43 +0000 (14:35 +0200)
modules/rebinding/rebinding.lua

index 171e5edcdb1cbdf0dcdabf3345c9fe0634db936b..d8b9f66275ffb19c5ee2311e362940cb3bb99a91 100644 (file)
@@ -4,6 +4,7 @@ local ffi = require('ffi')
 -- Protection from DNS rebinding attacks
 local kres = require('kres')
 local renumber = require('kres_modules.renumber')
+local policy = require('kres_modules.policy')
 
 local M = {}
 M.layer = {}
@@ -69,19 +70,8 @@ local function check_pkt(pkt)
 end
 
 local function refuse(req)
-       -- we are deleting packet in consume() phase so other modules
-       -- might have chosen some RRs from the original packet already
-       -- *_selected arrays are in mempool
-       -- so explicit deallocation is not necessary
-       req.answ_selected.len = 0
-       req.auth_selected.len = 0
-       req.add_selected.len = 0
-
-       -- construct brand new answer packet
+       policy.REFUSE(nil, req)
        local pkt = req.answer
-       pkt:clear_payload()
-       pkt:rcode(kres.rcode.REFUSED)
-       pkt:ad(false)
        pkt:aa(false)
        pkt:begin(kres.section.ADDITIONAL)