]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Now use the moderen method in the example script
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 4 Feb 2022 09:05:44 +0000 (10:05 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 4 Feb 2022 09:16:20 +0000 (10:16 +0100)
pdns/recursordist/contrib/powerdns-example-script.lua
pdns/recursordist/docs/lua-scripting/dq.rst
pdns/recursordist/docs/lua-scripting/hooks.rst
pdns/recursordist/docs/upgrade.rst

index 979f3352131a8e1df1703678bfc494230114d1ef..d98e7200f7d2c3bc37afafd689824ff9c4db14c6 100644 (file)
@@ -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
index a2c3655113a57768816d7a9d916dcb54b268737d..bc840d8497343330dbd33001db1a3322b42dd5d1 100644 (file)
@@ -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
index 75c428b0769e4bcf97d3bb71ee6e6de4ffb08342..3eddb15d6bc0dfd4d45ef7bcecfee9fec7666733 100644 (file)
@@ -211,7 +211,7 @@ Interception Functions
 
   :param :class:`PolicyEvent` event: The event to handle
 
- .. _hooksemantics:
+ .. _hook-semantics:
 
 Callback Semantics
 ^^^^^^^^^^^^^^^^^^
index e90c467732fa655235cb4764efc60c19989e0966..648e0cd5c5e487088349db63a5bcdc0d7392a874 100644 (file)
@@ -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
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^