blockset = newDS()
blockset:add{"powerdns.org", "xxx"}
-dropset = newDS();
+dropset = newDS()
dropset:add("123.cn")
malwareset = newDS()
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)
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
.. 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
:param :class:`PolicyEvent` event: The event to handle
- .. _hooksemantics:
+ .. _hook-semantics:
Callback Semantics
^^^^^^^^^^^^^^^^^^
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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^