From: Vladimír Čunát Date: Tue, 24 Apr 2018 14:14:29 +0000 (+0200) Subject: policy docs: replace incorrect example X-Git-Tag: v2.4.0~47^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e2162089c9523bacd90f2cbdb366b7e59fc86ec;p=thirdparty%2Fknot-resolver.git 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). --- 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