From: Otto Moerbeek Date: Fri, 4 Feb 2022 09:05:44 +0000 (+0100) Subject: Now use the moderen method in the example script X-Git-Tag: auth-4.7.0-alpha1~20^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcea35202ba63f1f2be07b1e8616518588d9d39b;p=thirdparty%2Fpdns.git Now use the moderen method in the example script --- diff --git a/pdns/recursordist/contrib/powerdns-example-script.lua b/pdns/recursordist/contrib/powerdns-example-script.lua index 979f335213..d98e7200f7 100644 --- a/pdns/recursordist/contrib/powerdns-example-script.lua +++ b/pdns/recursordist/contrib/powerdns-example-script.lua @@ -3,7 +3,7 @@ pdnslog("pdns-recursor Lua script starting!", pdns.loglevels.Warning) blockset = newDS() blockset:add{"powerdns.org", "xxx"} -dropset = newDS(); +dropset = newDS() dropset:add("123.cn") malwareset = newDS() @@ -67,14 +67,15 @@ function preresolve(dq) if dq.qtype == pdns.A then dq:addAnswer(pdns.A, "1.2.3.4") dq:addAnswer(pdns.TXT, "\"Hello!\"", 3601) -- ttl - return true; + return true end end if dropset:check(dq.qname) then - dq.rcode = pdns.DROP - return true; + pdnslog("dopping query") + dq.appliedPolicy.policyKind = pdns.policykinds.Drop + return false -- recursor still needs to handle the policy end if malwareset:check(dq.qname) @@ -82,10 +83,10 @@ function preresolve(dq) dq:addAnswer(pdns.CNAME, "blog.powerdns.com.") dq.rcode = 0 dq.followupFunction = "followCNAMERecords" -- this makes PowerDNS lookup your CNAME - return true; + return true end - return false; + return false end -- this implements DNS64 diff --git a/pdns/recursordist/docs/lua-scripting/dq.rst b/pdns/recursordist/docs/lua-scripting/dq.rst index a2c3655113..bc840d8497 100644 --- a/pdns/recursordist/docs/lua-scripting/dq.rst +++ b/pdns/recursordist/docs/lua-scripting/dq.rst @@ -40,7 +40,7 @@ The DNSQuestion object contains at least the following fields: .. attribute:: DNSQuestion.rcode current DNS Result Code, which can be overridden, including to several magical values. - Before 4.4.0, the rcode can be set to ``pdns.DROP`` to drop the query, for later versions refer to :ref:`hooksemantics`. + Before 4.4.0, the rcode can be set to ``pdns.DROP`` to drop the query, for later versions refer to :ref:`hook-semantics`. Other statuses are normal DNS return codes, like ``pdns.NOERROR``, ``pdns.NXDOMAIN`` etc. .. attribute:: DNSQuestion.isTcp diff --git a/pdns/recursordist/docs/lua-scripting/hooks.rst b/pdns/recursordist/docs/lua-scripting/hooks.rst index 75c428b076..3eddb15d6b 100644 --- a/pdns/recursordist/docs/lua-scripting/hooks.rst +++ b/pdns/recursordist/docs/lua-scripting/hooks.rst @@ -211,7 +211,7 @@ Interception Functions :param :class:`PolicyEvent` event: The event to handle - .. _hooksemantics: + .. _hook-semantics: Callback Semantics ^^^^^^^^^^^^^^^^^^ diff --git a/pdns/recursordist/docs/upgrade.rst b/pdns/recursordist/docs/upgrade.rst index e90c467732..648e0cd5c5 100644 --- a/pdns/recursordist/docs/upgrade.rst +++ b/pdns/recursordist/docs/upgrade.rst @@ -117,7 +117,7 @@ See :ref:`rpz` for details. Additionally a new type of callback has been introdu Dropping queries from Lua callbacks ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The method to drop a query from a Lua callback has been changed. -Previously, you could set `rcode` to `pdns.DROP`. See :ref:`hooksemantics` for the new method. +Previously, you could set `rcode` to `pdns.DROP`. See :ref:`hook-semantics` for the new method. Parsing of unknown record types ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^