From 0e2162089c9523bacd90f2cbdb366b7e59fc86ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Tue, 24 Apr 2018 16:14:29 +0200 Subject: [PATCH] policy docs: replace incorrect example The example didn't work and I don't immediately see how to quickly fix it, so let's have another more complex example instead (fished from an older forum post of mine). --- modules/policy/README.rst | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/policy/README.rst b/modules/policy/README.rst index 034aeba84..73d8feebe 100644 --- a/modules/policy/README.rst +++ b/modules/policy/README.rst @@ -108,12 +108,23 @@ Policy examples policy.add(policy.pattern(policy.PASS, '\4www[0-9]\6badboy\2cz')) -- Block all names below badboy.cz policy.add(policy.suffix(policy.DENY, {todname('badboy.cz.')})) + -- Custom rule - policy.add(function (req, query) - if query:qname():find('%d.%d.%d.224\7in-addr\4arpa') then - return policy.DENY + local ffi = require('ffi') + local function genRR (state, req) + local answer = req.answer + local qry = req:current() + if qry.stype ~= kres.type.A then + return state end - end) + ffi.C.kr_pkt_make_auth_header(answer) + answer:rcode(kres.rcode.NOERROR) + answer:begin(kres.section.ANSWER) + answer:put(qry.sname, 900, answer:qclass(), kres.type.A, '\192\168\1\3') + return kres.DONE + end + policy.add(policy.suffix(genRR, { todname('my.example.cz.') })) + -- Disallow ANY queries policy.add(function (req, query) if query.stype == kres.type.ANY then -- 2.47.2